From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Robin Murphy" <robin.murphy@arm.com>,
"Joerg Roedel" <jroedel@suse.de>,
"Sasha Levin" <sashal@kernel.org>,
will@kernel.org, joro@8bytes.org, baolu.lu@linux.intel.com,
jgg@ziepe.ca, robh@kernel.org, jon@solid-run.com,
vladimir.oltean@nxp.com, linux-arm-kernel@lists.infradead.org,
iommu@lists.linux.dev
Subject: [PATCH AUTOSEL 6.3 12/18] iommu/arm-smmu: Drop if with an always false condition
Date: Tue, 9 May 2023 17:19:20 -0400 [thread overview]
Message-ID: <20230509211928.21010-12-sashal@kernel.org> (raw)
In-Reply-To: <20230509211928.21010-1-sashal@kernel.org>
From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
[ Upstream commit a2972cb89935160bfe515b15d28a77694723ac06 ]
The remove and shutdown callback are only called after probe completed
successfully. In this case platform_set_drvdata() was called with a
non-NULL argument and so smmu is never NULL. Other functions in this
driver also don't check for smmu being non-NULL before using it.
Also note that returning an error code from a remove callback doesn't
result in the device staying bound. It's still removed and devm allocated
resources are freed (among others *smmu and the register mapping). So
after an early exit to iommu device stayed around and using it probably
oopses.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Link: https://lore.kernel.org/r/20230321084125.337021-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/iommu/arm/arm-smmu/arm-smmu.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
index 2ff7a72cf3772..f4a36533ae478 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
@@ -2195,9 +2195,6 @@ static void arm_smmu_device_shutdown(struct platform_device *pdev)
{
struct arm_smmu_device *smmu = platform_get_drvdata(pdev);
- if (!smmu)
- return;
-
if (!bitmap_empty(smmu->context_map, ARM_SMMU_MAX_CBS))
dev_notice(&pdev->dev, "disabling translation\n");
@@ -2218,9 +2215,6 @@ static int arm_smmu_device_remove(struct platform_device *pdev)
{
struct arm_smmu_device *smmu = platform_get_drvdata(pdev);
- if (!smmu)
- return -ENODEV;
-
iommu_device_unregister(&smmu->iommu);
iommu_device_sysfs_remove(&smmu->iommu);
--
2.39.2
next prev parent reply other threads:[~2023-05-09 21:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-09 21:19 [PATCH AUTOSEL 6.3 01/18] RDMA/core: Fix multiple -Warray-bounds warnings Sasha Levin
2023-05-09 21:19 ` [PATCH AUTOSEL 6.3 02/18] KVM: selftests: Add 'malloc' failure check in vcpu_save_state Sasha Levin
2023-05-09 21:19 ` [PATCH AUTOSEL 6.3 03/18] iommu/arm-smmu-qcom: Limit the SMR groups to 128 Sasha Levin
2023-05-09 21:19 ` [PATCH AUTOSEL 6.3 04/18] fs/ntfs3: Fix NULL pointer dereference in 'ni_write_inode' Sasha Levin
2023-05-09 21:19 ` [PATCH AUTOSEL 6.3 05/18] fs/ntfs3: Enhance the attribute size check Sasha Levin
2023-05-09 21:19 ` [PATCH AUTOSEL 6.3 06/18] fs/ntfs3: Fix NULL dereference in ni_write_inode Sasha Levin
2023-05-09 21:19 ` [PATCH AUTOSEL 6.3 07/18] fs/ntfs3: Validate MFT flags before replaying logs Sasha Levin
2023-05-09 21:19 ` [PATCH AUTOSEL 6.3 08/18] fs/ntfs3: Add length check in indx_get_root Sasha Levin
2023-05-09 21:19 ` [PATCH AUTOSEL 6.3 09/18] fs/ntfs3: Fix a possible null-pointer dereference in ni_clear() Sasha Levin
2023-05-09 21:19 ` [PATCH AUTOSEL 6.3 10/18] clk: tegra20: fix gcc-7 constant overflow warning Sasha Levin
2023-05-09 21:19 ` [PATCH AUTOSEL 6.3 11/18] iommu/arm-smmu-v3: Acknowledge pri/event queue overflow if any Sasha Levin
2023-05-09 21:19 ` Sasha Levin [this message]
2023-05-09 21:19 ` [PATCH AUTOSEL 6.3 13/18] iommu/sprd: Release dma buffer to avoid memory leak Sasha Levin
2023-05-09 21:19 ` [PATCH AUTOSEL 6.3 14/18] power: supply: axp288_charger: Use alt usb-id extcon on some x86 android tablets Sasha Levin
2023-05-09 21:19 ` [PATCH AUTOSEL 6.3 15/18] Input: xpad - add constants for GIP interface numbers Sasha Levin
2023-05-09 21:19 ` [PATCH AUTOSEL 6.3 16/18] RDMA/mlx5: Remove pcie_relaxed_ordering_enabled() check for RO write Sasha Levin
2023-05-09 21:19 ` [PATCH AUTOSEL 6.3 17/18] clk: rockchip: rk3588: make gate linked clocks critical Sasha Levin
2023-05-09 21:19 ` [PATCH AUTOSEL 6.3 18/18] cifs: missing lock when updating session status Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230509211928.21010-12-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=jon@solid-run.com \
--cc=joro@8bytes.org \
--cc=jroedel@suse.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=robin.murphy@arm.com \
--cc=stable@vger.kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
--cc=vladimir.oltean@nxp.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox