From patchwork Tue Oct 27 13:53:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 307300 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 0F4C4C55178 for ; Tue, 27 Oct 2020 16:44:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A861121D24 for ; Tue, 27 Oct 2020 16:44:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603817075; bh=XLI/NOokBRA6gBaE06J/9paKY2OWSWhNWDhiFF8wstk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=aln22+XmdleIc4G6C0Jy1yldbwGxplT6qKqv5iXV+Iex1VAoKv9SAvaN9muO0pnPn ROi8Q/V/jlHS2jdQqNHFl+3fcj5/gZaF7VLKb37vskdZRTqy1gXJscC5SJCBCj0Khq mfW9nE6pTZO3NQiL/nEvVg95MdpiBwe8iVtv7Yqw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1811949AbgJ0Qob (ORCPT ); Tue, 27 Oct 2020 12:44:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:35182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1801613AbgJ0Pm5 (ORCPT ); Tue, 27 Oct 2020 11:42:57 -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 DC9DE21D42; Tue, 27 Oct 2020 15:42:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603813375; bh=XLI/NOokBRA6gBaE06J/9paKY2OWSWhNWDhiFF8wstk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GHAwSVHqEPuwUHpWKAxaIkWPncDA0gc7cvlFmGXhMNUliApnr7AbSZVDzquMzd8qf 06Fse/FTBFrblvQG9yctKvog87kTlecbU2E01SLlQ9ZkLR25G6qOjF3dawpc1iP4Mp wZPbFQqPW6bHEZEf08YFGFQpFI8LOIGwJdpRWIP4= 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.9 530/757] vfio: fix a missed vfio group put in vfio_pin_pages Date: Tue, 27 Oct 2020 14:53:00 +0100 Message-Id: <20201027135515.353178869@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135450.497324313@linuxfoundation.org> References: <20201027135450.497324313@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 532bcaf28c11d..2151bc7f87ab1 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -1949,8 +1949,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)