Received: by 10.192.165.156 with SMTP id m28csp483535imm; Wed, 11 Apr 2018 02:22:38 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+M8Odi52ut9xAidbF3NoKe6JH6pg74hMtw09/pmXapy9DBrNRBELTJpRM6W0LHQl/ougEi X-Received: by 2002:a17:902:748a:: with SMTP id h10-v6mr4285564pll.160.1523438558392; Wed, 11 Apr 2018 02:22:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523438558; cv=none; d=google.com; s=arc-20160816; b=ozduTiWgEiWotJ1wtWehjV1pULTBTd7m1mwiVyt46VNY7R2gAiCWXc3vPfGz1q2UoQ RbX4Hnn9n8ql82rLKZXd3y7ZQflYgiyj+V0l8CuVX9NpYrB/kNqSOc3we52JxUjbKRRh qe1NQyV2QGhd7vra/3LywqrGeczoss48okBCxWy8DLzqYaS8/VGyfKJDOmneVAX4gDca TEnQ9liLxetLynOpQRAemDaDyHzzUvzAS8XsUadhycvtGQ5XYtKplt9cBnYJmN9U7YUg 91RDbxo0GGxxnyzZ13k7/NlXBk7knwxty6o0fJ3Zmqa+CddUjo+VG2DZxg7J/6H1vVNR 82qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=k6BD4LvNJA7ZQJlbMpq3vhKna0QzpAw0NwDAQ3YIqJ0=; b=eguU4kbOUkXHQrzjfUcqYbjVclI/Svg9kxTYqPBKgU+cgq90E59Zn2aj8ANll4m2Y4 3Z5lvf3b1Z7cht+5+YbRqLdl0auvML2uoCuQ3W6zHBRx2JGR+Q8O6Dun+/aiV+0N31Iz VhY59rbH72glGbcjqrn/4Tk4Ot6NIFkBHF4l92zxopFNkdSuawnni9fe4oV8FZLOL/vh XwAFr9dOHzlDoTNYgen9IMbT8Lhjwu5EJ9sKKxTWnOlI0ifm8W/0HxWY0YCJNYcxUhot lwOOe9940K+/YnzIP/ISkreBkMXqRe/3hCcEs61IkZSLfU/uGEMtk5aQbQ/8n/bofABo RXpg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s9si472628pgc.202.2018.04.11.02.22.01; Wed, 11 Apr 2018 02:22:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752822AbeDKJR2 (ORCPT + 99 others); Wed, 11 Apr 2018 05:17:28 -0400 Received: from andre.telenet-ops.be ([195.130.132.53]:51716 "EHLO andre.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752167AbeDKJPy (ORCPT ); Wed, 11 Apr 2018 05:15:54 -0400 Received: from ayla.of.borg ([84.194.111.163]) by andre.telenet-ops.be with bizsmtp id YxFs1x00K3XaVaC01xFsDC; Wed, 11 Apr 2018 11:15:52 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.86_2) (envelope-from ) id 1f6Br6-0002Cv-9C; Wed, 11 Apr 2018 11:15:52 +0200 Received: from geert by ramsan with local (Exim 4.86_2) (envelope-from ) id 1f6Br6-0004IC-7p; Wed, 11 Apr 2018 11:15:52 +0200 From: Geert Uytterhoeven To: Baptiste Reynal , Alex Williamson Cc: Philipp Zabel , Rob Herring , Mark Rutland , kvm@vger.kernel.org, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v3 1/2] vfio: platform: Fix reset module leak in error path Date: Wed, 11 Apr 2018 11:15:48 +0200 Message-Id: <1523438149-16433-3-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523438149-16433-1-git-send-email-geert+renesas@glider.be> References: <1523438149-16433-1-git-send-email-geert+renesas@glider.be> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the IOMMU group setup fails, the reset module is not released. Fixes: b5add544d677d363 ("vfio, platform: make reset driver a requirement by default") Signed-off-by: Geert Uytterhoeven Reviewed-by: Eric Auger Reviewed-by: Simon Horman --- v3: - Add Reviewed-by, v2: - Add Reviewed-by. --- drivers/vfio/platform/vfio_platform_common.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c index 35469af87f88678e..b60bb5326668498c 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -680,18 +680,23 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev, group = vfio_iommu_group_get(dev); if (!group) { pr_err("VFIO: No IOMMU group for device %s\n", vdev->name); - return -EINVAL; + ret = -EINVAL; + goto put_reset; } ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev); - if (ret) { - vfio_iommu_group_put(group, dev); - return ret; - } + if (ret) + goto put_iommu; mutex_init(&vdev->igate); return 0; + +put_iommu: + vfio_iommu_group_put(group, dev); +put_reset: + vfio_platform_put_reset(vdev); + return ret; } EXPORT_SYMBOL_GPL(vfio_platform_probe_common); -- 2.7.4