[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20201207112943.GC4379@willie-the-truck>
Date: Mon, 7 Dec 2020 11:29:43 +0000
From: Will Deacon <will@...nel.org>
To: Tian Tao <tiantao6@...ilicon.com>
Cc: robin.murphy@....com, joro@...tes.org, jean-philippe@...aro.org,
Jonathan.Cameron@...wei.com, song.bao.hua@...ilicon.com,
linux-arm-kernel@...ts.infradead.org,
iommu@...ts.linux-foundation.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iommu/arm-smmu-v3: Fix not checking return value about
devm_add_action
On Mon, Dec 07, 2020 at 07:23:29PM +0800, Tian Tao wrote:
> Use devm_add_action_or_reset to avoid the situation where the release
> function is not called when devm_add_action returns an error.
>
> Signed-off-by: Tian Tao <tiantao6@...ilicon.com>
>
> v2:
> check the return value about evm_add_action_or_reset()
> ---
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> index 2ddf5ec..76c28e7 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -2680,7 +2680,8 @@ static int arm_smmu_cmdq_init(struct arm_smmu_device *smmu)
> ret = -ENOMEM;
> } else {
> cmdq->valid_map = bitmap;
> - devm_add_action(smmu->dev, arm_smmu_cmdq_free_bitmap, bitmap);
> + ret = devm_add_action_or_reset(smmu->dev,
> + arm_smmu_cmdq_free_bitmap, bitmap);
> }
>
> return ret;
> @@ -2938,7 +2939,7 @@ static void arm_smmu_setup_msis(struct arm_smmu_device *smmu)
> }
>
> /* Add callback to free MSIs on teardown */
> - devm_add_action(dev, arm_smmu_free_msis, dev);
> + devm_add_action_or_reset(dev, arm_smmu_free_msis, dev);
Hmm, but you don't propagate the error here so couldn't this lead to a
use-after-free?
Will
Powered by blists - more mailing lists