From patchwork Tue Oct 27 13:53:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 307235 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75152C56202 for ; Tue, 27 Oct 2020 17:02:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E4772224A for ; Tue, 27 Oct 2020 17:02:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603818127; bh=ntyt1F34ZiEDyr6C3hbVye6v7FuMXWb0duiduz2krT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=kDyAZnGSmrD1mxqa7T77/9KiNKKVfaYal7O2cKBAs35hz2K1mCGpvgN7dE1MymbO5 UC5paTsgQHK51QRoywH0VBDYWfzIamqWGlqjnmNooU/xfq3DeJVDwZRHwKVLkNO6V0 TbLeswJixHXPduxJ9SR+YSEgwRjPpQTUCNRd16IE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1793788AbgJ0PIS (ORCPT ); Tue, 27 Oct 2020 11:08:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:43174 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1793754AbgJ0PII (ORCPT ); Tue, 27 Oct 2020 11:08:08 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 09A5121D41; Tue, 27 Oct 2020 15:08:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811286; bh=ntyt1F34ZiEDyr6C3hbVye6v7FuMXWb0duiduz2krT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1hN0OicUES9gP+49DxfXwu/QA6milghIpaUVDMYEdZsbvS3JiO7W/A/goBGdI37MU w16zaoZX7aw0w8KAwfdLaSbvGVVplS1IyyVL5syIf9sZHRUPizFGIuOnWTsqG2rqQm Ee4l3tVBn1Lt7M5rybmXWeFoHnJFoFMMmfDO66pE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yan Zhao , Cornelia Huck , Alex Williamson , Sasha Levin Subject: [PATCH 5.8 439/633] vfio: fix a missed vfio group put in vfio_pin_pages Date: Tue, 27 Oct 2020 14:53:02 +0100 Message-Id: <20201027135543.317608540@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Yan Zhao [ Upstream commit 28b130244061863cf0437b7af1625fb45ec1a71e ] When error occurs, need to put vfio group after a successful get. Fixes: 95fc87b44104 ("vfio: Selective dirty page tracking if IOMMU backed device pins pages") Signed-off-by: Yan Zhao Reviewed-by: Cornelia Huck Signed-off-by: Alex Williamson Signed-off-by: Sasha Levin --- drivers/vfio/vfio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 2a70e25cfe954..fbff5c4743c5e 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -1948,8 +1948,10 @@ int vfio_pin_pages(struct device *dev, unsigned long *user_pfn, int npage, if (!group) return -ENODEV; - if (group->dev_counter > 1) - return -EINVAL; + if (group->dev_counter > 1) { + ret = -EINVAL; + goto err_pin_pages; + } ret = vfio_group_add_container_user(group); if (ret)