Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2721796pxj; Mon, 31 May 2021 09:05:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5M5UoxpvAJzsPfoyWEX4rq+2aGINh5giISCQg7fjgGmbD9kWnljtsphi1dWPY6FtCYodN X-Received: by 2002:a05:6e02:1988:: with SMTP id g8mr13441768ilf.4.1622477156330; Mon, 31 May 2021 09:05:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622477156; cv=none; d=google.com; s=arc-20160816; b=BJLqA/fSu3b/Lw157Fn0qGIhdUWL1DE5G6xY6a+lhA37sN4DxKRiHLSJYTN7Yx4p6L gUO00DGAQ9sm9Z3TYULq0yiJNnekLCHWhXj+Dh7S5udbgBgwlCWQKZz9Z3wnuk1Z/rWU u0FTqBfvPi9XPLEzXmhv4k/zym6vM2bm/1Q70kpRYUQUnwGnKNxxKXKNkudhPNtJSFJK h7Jxgg7iCGKwqu11BXUk4bJ7l28SzpIh3yuG4LitA8mVA6r6bftuPnQUdSds7LkGb/H0 xl8p2l8ZRctmwVHNUD3OqsRaBymaEiqxxT6YX821+hvx0oPTyVDV7Fso2/9G7UPC1/48 EeGA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Aq7XQURnf6NdotJi0k3u+EGIoE6G9n4LaXIfgYB5hcc=; b=mZPHqI3SBf/oVkEmYu6OpNZiSNMZW1g8Smb0d6yvdkHpkdViH3oMvxM8SBonPbdxi6 weYxaqkQfKzko9YtnmOSeNjmXu3VWrthORuGouwudBJDBLLcVu5Ql725BxXFD2nIv02Z 9zbEGqfc5n/jMKx5LROwQdcEvaaAtWBLuBH8Jo3DOxRet/jm/HEbkzaB9g4yYoBMB9lV gQ9ivbW0wctyEWuST8PetNviMqi9F28axLxi0cUZzpRHjj9waEhZCZR8Hz0VX5xRx0b9 Sckz5JRAAkqqhzikxY4LcVFU036qeFWzwUsaibLEoaOsCoZDuaUDuBREx/gX5oEmoDJv r3JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zF9S1F0V; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y6si3398919ilq.94.2021.05.31.09.05.43; Mon, 31 May 2021 09:05:56 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zF9S1F0V; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233528AbhEaQGj (ORCPT + 99 others); Mon, 31 May 2021 12:06:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:33230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233538AbhEaOfh (ORCPT ); Mon, 31 May 2021 10:35:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3352F6162C; Mon, 31 May 2021 13:51:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469070; bh=qKGOX0Ss4HKPu86al1XwM/prUFx9xEBhjkjHeSxaE4Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zF9S1F0VU53pk58oO53igPdNQE8p04GEE2K4roMGM8SyXD4QGgKKebJifeLrfdWCP 72KKpEW3srOstIBpiZeBH/t8npKyMWxY4aFrYwmG/eZZbdOfy2nz6eQPmMmgyOw0Z/ +W49sWZ8Yhmkbc1LDbE+z/MpPVMmHtG55qOiJhLU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rolf Eike Beer , Lu Baolu , Joerg Roedel Subject: [PATCH 5.12 023/296] iommu/vt-d: Fix sysfs leak in alloc_iommu() Date: Mon, 31 May 2021 15:11:18 +0200 Message-Id: <20210531130704.546190537@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rolf Eike Beer commit 0ee74d5a48635c848c20f152d0d488bf84641304 upstream. 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 Acked-by: Lu Baolu Link: https://lore.kernel.org/r/17411490.HIIP88n32C@mobilepool36.emlix.com Link: https://lore.kernel.org/r/20210525070802.361755-2-baolu.lu@linux.intel.com Signed-off-by: Joerg Roedel Signed-off-by: Greg Kroah-Hartman --- drivers/iommu/intel/dmar.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/iommu/intel/dmar.c +++ b/drivers/iommu/intel/dmar.c @@ -1144,7 +1144,7 @@ static int alloc_iommu(struct dmar_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_ return 0; +err_sysfs: + iommu_device_sysfs_remove(&iommu->iommu); err_unmap: unmap_iommu(iommu); error_free_seq_id: