2019-09-04 08:15:52

by Joerg Roedel

[permalink] [raw]
Subject: Re: [PATCH 2/3] iommu/pamu: Use kzfree rather than its implementation

On Wed, Sep 04, 2019 at 11:01:18AM +0800, zhong jiang wrote:
> Use kzfree instead of memset() + kfree().
>
> Signed-off-by: zhong jiang <[email protected]>
> ---
> drivers/iommu/fsl_pamu.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iommu/fsl_pamu.c b/drivers/iommu/fsl_pamu.c
> index cde281b..ca6d147 100644
> --- a/drivers/iommu/fsl_pamu.c
> +++ b/drivers/iommu/fsl_pamu.c
> @@ -1174,10 +1174,8 @@ static int fsl_pamu_probe(struct platform_device *pdev)
> if (irq != NO_IRQ)
> free_irq(irq, data);
>
> - if (data) {
> - memset(data, 0, sizeof(struct pamu_isr_data));
> - kfree(data);
> - }
> + if (data)
> + kzfree(data);

kzfree() is doing its own NULL-ptr check, no need to do it here.

Regards,

Joerg


2019-09-04 09:39:22

by zhong jiang

[permalink] [raw]
Subject: Re: [PATCH 2/3] iommu/pamu: Use kzfree rather than its implementation

On 2019/9/4 16:15, Joerg Roedel wrote:
> On Wed, Sep 04, 2019 at 11:01:18AM +0800, zhong jiang wrote:
>> Use kzfree instead of memset() + kfree().
>>
>> Signed-off-by: zhong jiang <[email protected]>
>> ---
>> drivers/iommu/fsl_pamu.c | 6 ++----
>> 1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/iommu/fsl_pamu.c b/drivers/iommu/fsl_pamu.c
>> index cde281b..ca6d147 100644
>> --- a/drivers/iommu/fsl_pamu.c
>> +++ b/drivers/iommu/fsl_pamu.c
>> @@ -1174,10 +1174,8 @@ static int fsl_pamu_probe(struct platform_device *pdev)
>> if (irq != NO_IRQ)
>> free_irq(irq, data);
>>
>> - if (data) {
>> - memset(data, 0, sizeof(struct pamu_isr_data));
>> - kfree(data);
>> - }
>> + if (data)
>> + kzfree(data);
> kzfree() is doing its own NULL-ptr check, no need to do it here.
Yep, we should also remove the condition before kzfree. will repost.

Thanks,
zhong jiang
> Regards,
>
> Joerg