Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2687102pxj; Mon, 31 May 2021 08:15:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhHBxrsu/dCfqhz6+LwEqlZjcc6fgU0itxwNa0F5CxV1Rykvhztwi8j9HXu4Pv4AV5uRQs X-Received: by 2002:a5e:a806:: with SMTP id c6mr16847763ioa.180.1622474147208; Mon, 31 May 2021 08:15:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622474147; cv=none; d=google.com; s=arc-20160816; b=aGw4HKSNp68fhQ1SIA0QDX4+ujN2XBwvpyE5+qf1c+AVzP/l1EORQJbFloHMk83scC fj9KQq2Vyr5rEsqdmGiU3w5ky5CsNns58sMAFBfWTzLyzAsrF9lnmxRIkHQGfoGG8+O1 88cL0OMV+uD3aWu9SHcg2eAjYe+tmdrCE8cx08a4SYqUCZLM3NII8yf5BP3VGtromg5z lboLqrwl31o2hVsy4zrOJYX4xDjK2W8vukA9r7iQRf8WpTA8azynvz3jo8AWFmPFfysB CJAyEzdBx7V6yKMYpNWqAAg+dLoZIIgU44q4XRNx3ToaDkrJOjKnCRpJJC72S9Kih0EC oKMw== 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=8prnaOlzYSnELYekyGugZYRhiPy2RXYBL7Rn9NZvNWU=; b=WULaZXP3+3Lu4lX7L0OcZkUqxx61gIaOFCCmOt4wqj/Y/wbtQEjA27a5/5XM11dWOX jWpuBUfSC7s1lz47SVYh2hcmpXD9/gOUnMGtoQkLbgDMK0RL95jEO50DDGnlQyF0PqL1 IKpcn3L4YJizULFkMPuyoMcmbJIgSs9UwsD7R4w+HbZ76u/bL36hd4hVRgdUNOesQ0du oJoxhaWrOOiYTQT88GihTDrC2XxhOkTc05PmZguIHvlA7MbarAKyBcI0dv1xfkrSHnmt I/8XDWJjQE+Ygu1TN9iiq5jkLh6RrH6SAklYOLNKtbAanrwYpSHg5M0+KB1pBjgyGCso wKag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=W152PQWj; 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 l12si473768ilf.96.2021.05.31.08.15.33; Mon, 31 May 2021 08:15:47 -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=W152PQWj; 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 S233249AbhEaPPc (ORCPT + 99 others); Mon, 31 May 2021 11:15:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:40812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233291AbhEaOMm (ORCPT ); Mon, 31 May 2021 10:12:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9F1D961464; Mon, 31 May 2021 13:41:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468503; bh=qKfDJFOx3qOkVAAvCD5wyxj6YgBgUGKf8FZajOoOjNE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W152PQWjGojUpT6jMQ6buDUW+r3U6CqM3cMAXhxFP7OAWu3j7gJnmVrhUYqAwbBT2 KZ9eL9NFe3zQ+V07WIahobm6+Ll5qnmcHkU7RetobjRyRcnoB+UEPtkufTDFlYrka1 HSmHZCIqyNAI2giDadKwpIs6wEBfpebDucCNXanE= 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.4 006/177] iommu/vt-d: Fix sysfs leak in alloc_iommu() Date: Mon, 31 May 2021 15:12:43 +0200 Message-Id: <20210531130648.116306945@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130647.887605866@linuxfoundation.org> References: <20210531130647.887605866@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/dmar.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/iommu/dmar.c +++ b/drivers/iommu/dmar.c @@ -1110,7 +1110,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; @@ -1118,6 +1118,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: