From mboxrd@z Thu Jan 1 00:00:00 1970 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 56A82351C04; Fri, 4 Sep 2026 05:29:45 +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=1788499786; cv=none; b=iUeLQoWPZBn6M/pSv+oluiz5H8DlX8ZzOIRXBsSgpGRzbhkR/0IyaPFj18yCenswdDa95zmqwLzw8SBGAhq7+a3hmcMjexYyyXBwIXZ7aaxMWStA8TWxvYp3oDfi0pX3ybX3n+kiHOyLb2Rkt5fxzdf81HjTbu66ND5cIN6zjMk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788499786; c=relaxed/simple; bh=yvM4UeEI/Sux7/msoXkF+ZEUGJl/5frj1ScBtgnj07Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X/7AO447fRCpmKVcF9h2I8YSpzy1ChkK840w65GdHIpCvqwHQ9wvbBElYSCFbY7j23eIvDMFmIo6eczRP2bhcfXDd/d6H/yNs+4WkebE5vDSiu8j7tkC6ZNS8VR59NBzUxJlimi2zYA9ZaMQnCFivlweXKv4ER7TqC2SisRGE+Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=OPuJsE52; 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="OPuJsE52" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7C601F00A3D; Fri, 4 Sep 2026 05:29:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788499785; bh=3guxwFNL43mHqStK3cGZv3FYL1QsySbjMf1iuz1jXGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OPuJsE52ARpEAPwKunQPy38vDCO2ZdruNxy8ELqQYCdka3DqnLglMjptLjwkAg9/f ApFMm3E2nTgXNUM7uhyXwjQa6J1FhP995R9mHfT69z9Em8AukAlutJp96kSumbGboF ALzXjAl3uc2ZBXEs1QKrNsjKgJ859ryFeEscvpmI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mukesh Ojha , Weimin Xiong , Will Deacon Subject: [PATCH 7.2 538/713] iommu/msm: Unwind probe state on registration failure Date: Fri, 4 Sep 2026 06:58:26 +0200 Message-ID: <20260904045815.881204874@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260904045803.810145556@linuxfoundation.org> References: <20260904045803.810145556@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 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Weimin Xiong commit 535a200220ca2c83bc8bf54bd2cbe045d6ee70c4 upstream. 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: Greg Kroah-Hartman --- drivers/iommu/msm_iommu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/drivers/iommu/msm_iommu.c +++ b/drivers/iommu/msm_iommu.c @@ -784,19 +784,25 @@ static int msm_iommu_probe(struct platfo "msm-smmu.%pa", &ioaddr); if (ret) { pr_err("Could not add msm-smmu at %pa to sysfs\n", &ioaddr); - return ret; + 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); - return ret; + 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); + return ret; } static const struct of_device_id msm_iommu_dt_match[] = {