Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 396FE350A0F; Sat, 17 Oct 2026 17:53:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792259611; cv=none; b=AuNt8kcLJqeUVAPPDVacp79TlE7fKqdO6HZYxi6DovLeyl33c7Bfq9KthLYgss4CudbqX/yKpS/MwM1Epurm4cg70cP+eCS5eS5JE8IiuyqwHzRk34JeGFP/waIcb8Q3nWCww7tTDKYRyNuz6Z89zDQKj7c8yvWLMz2G8y+0qC8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792259611; c=relaxed/simple; bh=McuWrCvPj9zI7BxFEJFoL/bX3Qdn2SRaBBA9cmmg6qM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XKP0ddIBwo2AL9AuJJzlHN8b4Of1DGagwFo331PRq7RRrEv3PsJQgqp1urxNQQjvc364T52fip19WoCc/p3qomD+wNTwx0t4hLBWDXtFRvvu5NlgQ1nazDroGGrECaplLhgqRqpUV/YjI0yekKRw8B6/3ygqnQK1t9EE6y0OF0U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ztxA11bF; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ztxA11bF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 883CF1F000C4; Sat, 17 Oct 2026 17:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792259610; bh=nsq/DI32FyPgSWSDmeRqI0VP2HTT/1JofUsWioBVGjw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ztxA11bFH+q/LOSmpjdRP1+4fVJqKhueCe1DcqQzGESlT36f9ZpJBm9fuKR+GMOUV r+zcB3jjQ/7cwSl03rn7gL9VOxxSTN5vpz5wsN9HrYwvPnGYXkKb3s6pZ/h3+tzK4p o3rTI0jxyHSEsNvZwEWoosMi2UvR2cP+VGdhGvoI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mukesh Ojha , Weimin Xiong , Will Deacon , Sasha Levin Subject: [PATCH 6.6 1270/1674] iommu/msm: Unwind probe state on registration failure Date: Sat, 17 Oct 2026 17:59:02 +0200 Message-ID: <20261017160503.741050130@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261017160431.119607952@linuxfoundation.org> References: <20261017160431.119607952@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Weimin Xiong [ Upstream commit 535a200220ca2c83bc8bf54bd2cbe045d6ee70c4 ] msm_iommu_probe() adds its devm-managed IOMMU object to qcom_iommu_devices before adding the IOMMU sysfs device and registering it with the IOMMU core. If iommu_device_sysfs_add() fails, probe returns with the object still on qcom_iommu_devices. The driver core then releases the devm allocation, leaving a dangling list entry that later list walks may dereference. If iommu_device_register() fails, the same dangling list entry remains and the sysfs device is left registered as well. Unwind the sysfs device and global list entry in reverse setup order on the corresponding failure paths. Fixes: 42df43b36163 ("iommu/msm: Make use of iommu_device_register interface") Cc: stable@vger.kernel.org Reviewed-by: Mukesh Ojha Signed-off-by: Weimin Xiong Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- drivers/iommu/msm_iommu.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c index be94bb16f627b..1aff96d655b37 100644 --- a/drivers/iommu/msm_iommu.c +++ b/drivers/iommu/msm_iommu.c @@ -787,19 +787,24 @@ static int msm_iommu_probe(struct platform_device *pdev) "msm-smmu.%pa", &ioaddr); if (ret) { pr_err("Could not add msm-smmu at %pa to sysfs\n", &ioaddr); - goto fail; + goto err_remove_list; } ret = iommu_device_register(&iommu->iommu, &msm_iommu_ops, &pdev->dev); if (ret) { pr_err("Could not register msm-smmu at %pa\n", &ioaddr); - goto fail; + goto err_remove_sysfs; } pr_info("device mapped at %p, irq %d with %d ctx banks\n", iommu->base, iommu->irq, iommu->ncb); return ret; + +err_remove_sysfs: + iommu_device_sysfs_remove(&iommu->iommu); +err_remove_list: + list_del(&iommu->dev_node); fail: clk_unprepare(iommu->clk); clk_unprepare(iommu->pclk); -- 2.53.0