[PATCH 01/10] iommu/arm-smmu: Drop if with an always false condition
Robin Murphy
robin.murphy at arm.com
Tue Mar 28 07:10:17 PDT 2023
On 21/03/2023 8:41 am, Uwe Kleine-König wrote:
> 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.
Indeed, it seems this impossible condition has been here since day 1;
shame on me for not paying more attention when Vladimir dutifully
refactored it :)
Reviewed-by: Robin Murphy <robin.murphy at arm.com>
> 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 at pengutronix.de>
> ---
> 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 2ff7a72cf377..f4a36533ae47 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);
>
More information about the linux-arm-kernel
mailing list