Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp177895pxy; Wed, 21 Apr 2021 22:42:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxA9Lf6o3M+02MbD60CGxwhuWrai7Gu+ffHBqPRZu1VOV4ila/wnnKYaGvZWbunxDKKsnft X-Received: by 2002:a17:906:1c17:: with SMTP id k23mr1561069ejg.266.1619070147577; Wed, 21 Apr 2021 22:42:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619070147; cv=none; d=google.com; s=arc-20160816; b=JuJw8VymA5xhQ9ujV0r0VQj5LN/VG6YK/ENJlGzOBSpHR9es0pS+3JdaXpbGeEhJCn PIjDLGKQLaTeKpSNONkC8QXpOYRQWpd/CWAam8rufiIjEeQJOGepjTpFp3a0YvTqn0pl iHs96SlzfWgNg4daM9KkAIKqtIzPJh7Cx6HHCq1WirCi3B+TgrjJ3jxO3S2Mrzg+InXf lZPhPdT1Aoan44vXplbytDW0v6EEMKIpuQRo+NaoHE26j4Ovyg+q9ytwB0I4NsPJZHjj CaufBxlzGncKC5vSsPnDyjthqn3+3R7sX9AgTAkL77ByskZrUH88W9mBm/s6HZEGgPWs Xs8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=AQ8pnlsXqnPIQ9Wvp4FcrkMa8a3SKf5KyFzCw7TTe/A=; b=d6FN6yhUeYOMKTeNsIFmz1+LEs1InwkfGIIYx6V1YXRBDwiQ8T+nO+GCVf/j/1oJBS nVhJycI4mjddaZdG+aJOn5z4OPQbhRK+Jv/vfIJ2F36jYG5z3+Ja8QTPduA7SFwNEaYh H8swBrG1r71AbduA/S+9C+OOI+XZEZhx8LfrC5RimBfcuG+xW+SPOdh+Ffz5uILOQaIx 9MczH0Sk2+RnTaM5XkXZP+SEdrGlfg9ZSueMiw93OHPYNKu1jJ9+cDSuNaB+qL60ZNo/ 8KwjgUw6IMVdoMz9CHWy7o8SwCk7B4sp6J9SAN7htgGkFcRwjr8chgN5BRLDxZkhDaDk xLkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s23si1246002edc.25.2021.04.21.22.42.03; Wed, 21 Apr 2021 22:42:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231631AbhDVFkW convert rfc822-to-8bit (ORCPT + 99 others); Thu, 22 Apr 2021 01:40:22 -0400 Received: from mx1.emlix.com ([136.243.223.33]:35988 "EHLO mx1.emlix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230128AbhDVFkV (ORCPT ); Thu, 22 Apr 2021 01:40:21 -0400 Received: from mailer.emlix.com (unknown [81.20.119.6]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.emlix.com (Postfix) with ESMTPS id 630016049E; Thu, 22 Apr 2021 07:39:46 +0200 (CEST) From: Rolf Eike Beer To: Joerg Roedel , Will Deacon Cc: David Woodhouse , Lu Baolu , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH] iommu/vt-d: Fix sysfs leak in alloc_domain() Date: Thu, 22 Apr 2021 07:39:44 +0200 Message-ID: <17411490.HIIP88n32C@mobilepool36.emlix.com> In-Reply-To: <1716403.SmlLz2RZUD@devpool47> References: <1716403.SmlLz2RZUD@devpool47> MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org iommu_device_sysfs_add() is called before, so is has to be cleaned on subsequent errors. Fixes: 39ab9555c2411 ("iommu: Add sysfs bindings for struct iommu_device") Cc: stable@vger.kernel.org # 4.11.x Signed-off-by: Rolf Eike Beer --- drivers/iommu/intel/dmar.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c index d5c51b5c20af..c2bfccb19e24 100644 --- a/drivers/iommu/intel/dmar.c +++ b/drivers/iommu/intel/dmar.c @@ -1144,7 +1144,7 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd) err = iommu_device_register(&iommu->iommu); if (err) - goto err_unmap; + goto err_sysfs; } drhd->iommu = iommu; @@ -1152,6 +1152,8 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd) return 0; +err_sysfs: + iommu_device_sysfs_remove(&iommu->iommu); err_unmap: unmap_iommu(iommu); error_free_seq_id: -- 2.31.1 -- Rolf Eike Beer, emlix GmbH, https://www.emlix.com Fon +49 551 30664-0, Fax +49 551 30664-11 Gothaer Platz 3, 37083 Göttingen, Germany Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160 Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055 emlix - smart embedded open source