IOMMU Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/3] Use kzfree instead of memset() + kfree() 
@ 2019-09-04  3:01 zhong jiang
  2019-09-04  3:01 ` [PATCH 1/3] crypto: marvell: Use kzfree rather than its implementation zhong jiang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: zhong jiang @ 2019-09-04  3:01 UTC (permalink / raw)
  To: davem, herbert, arno, joro, gregkh
  Cc: iommu, zhongjiang, linux-crypto, linux-kernel

th the help of Coccinelle. We find some place to replace.

@@
expression M, S;
@@

- memset(M, 0, S);
- kfree(M);
+ kzfree(M); 

zhong jiang (3):
  crypto: marvell: Use kzfree rather than its implementation
  iommu/pamu: Use kzfree rather than its implementation
  Staging: rtl8723bs: Use kzfree rather than its implementation

 drivers/crypto/marvell/hash.c                 | 3 +--
 drivers/iommu/fsl_pamu.c                      | 6 ++----
 drivers/staging/rtl8723bs/core/rtw_security.c | 3 +--
 3 files changed, 4 insertions(+), 8 deletions(-)

-- 
1.7.12.4

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] crypto: marvell: Use kzfree rather than its implementation
  2019-09-04  3:01 [PATCH 0/3] Use kzfree instead of memset() + kfree() zhong jiang
@ 2019-09-04  3:01 ` zhong jiang
  2019-09-09  7:53   ` Herbert Xu
  2019-09-04  3:01 ` [PATCH 2/3] iommu/pamu: " zhong jiang
  2019-09-04  3:01 ` [PATCH 3/3] Staging: rtl8723bs: " zhong jiang
  2 siblings, 1 reply; 7+ messages in thread
From: zhong jiang @ 2019-09-04  3:01 UTC (permalink / raw)
  To: davem, herbert, arno, joro, gregkh
  Cc: iommu, zhongjiang, linux-crypto, linux-kernel

Use kzfree instead of memset() + kfree().

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 drivers/crypto/marvell/hash.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/crypto/marvell/hash.c b/drivers/crypto/marvell/hash.c
index 0f0ac85..a2b35fb 100644
--- a/drivers/crypto/marvell/hash.c
+++ b/drivers/crypto/marvell/hash.c
@@ -1148,8 +1148,7 @@ static int mv_cesa_ahmac_pad_init(struct ahash_request *req,
 		}
 
 		/* Set the memory region to 0 to avoid any leak. */
-		memset(keydup, 0, keylen);
-		kfree(keydup);
+		kzfree(keydup);
 
 		if (ret)
 			return ret;
-- 
1.7.12.4

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/3] iommu/pamu: Use kzfree rather than its implementation
  2019-09-04  3:01 [PATCH 0/3] Use kzfree instead of memset() + kfree() zhong jiang
  2019-09-04  3:01 ` [PATCH 1/3] crypto: marvell: Use kzfree rather than its implementation zhong jiang
@ 2019-09-04  3:01 ` " zhong jiang
  2019-09-04  8:15   ` Joerg Roedel
  2019-09-04  3:01 ` [PATCH 3/3] Staging: rtl8723bs: " zhong jiang
  2 siblings, 1 reply; 7+ messages in thread
From: zhong jiang @ 2019-09-04  3:01 UTC (permalink / raw)
  To: davem, herbert, arno, joro, gregkh
  Cc: iommu, zhongjiang, linux-crypto, linux-kernel

Use kzfree instead of memset() + kfree().

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 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);
 
 	if (pamu_regs)
 		iounmap(pamu_regs);
-- 
1.7.12.4

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/3] Staging: rtl8723bs: Use kzfree rather than its implementation
  2019-09-04  3:01 [PATCH 0/3] Use kzfree instead of memset() + kfree() zhong jiang
  2019-09-04  3:01 ` [PATCH 1/3] crypto: marvell: Use kzfree rather than its implementation zhong jiang
  2019-09-04  3:01 ` [PATCH 2/3] iommu/pamu: " zhong jiang
@ 2019-09-04  3:01 ` " zhong jiang
  2 siblings, 0 replies; 7+ messages in thread
From: zhong jiang @ 2019-09-04  3:01 UTC (permalink / raw)
  To: davem, herbert, arno, joro, gregkh
  Cc: iommu, zhongjiang, linux-crypto, linux-kernel

Use kzfree instead of memset() + kfree().

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 drivers/staging/rtl8723bs/core/rtw_security.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
index 979056c..57cfe06 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -2290,8 +2290,7 @@ static void gf_mulx(u8 *pad)
 
 static void aes_encrypt_deinit(void *ctx)
 {
-	memset(ctx, 0, AES_PRIV_SIZE);
-	kfree(ctx);
+	kzfree(ctx);
 }
 
 
-- 
1.7.12.4

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] iommu/pamu: Use kzfree rather than its implementation
  2019-09-04  3:01 ` [PATCH 2/3] iommu/pamu: " zhong jiang
@ 2019-09-04  8:15   ` Joerg Roedel
  2019-09-04  9:38     ` zhong jiang
  0 siblings, 1 reply; 7+ messages in thread
From: Joerg Roedel @ 2019-09-04  8:15 UTC (permalink / raw)
  To: zhong jiang
  Cc: herbert, gregkh, arno, linux-kernel, iommu, linux-crypto, davem

On Wed, Sep 04, 2019 at 11:01:18AM +0800, zhong jiang wrote:
> Use kzfree instead of memset() + kfree().
> 
> Signed-off-by: zhong jiang <zhongjiang@huawei.com>
> ---
>  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
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] iommu/pamu: Use kzfree rather than its implementation
  2019-09-04  8:15   ` Joerg Roedel
@ 2019-09-04  9:38     ` zhong jiang
  0 siblings, 0 replies; 7+ messages in thread
From: zhong jiang @ 2019-09-04  9:38 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: herbert, gregkh, arno, linux-kernel, iommu, linux-crypto, davem

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 <zhongjiang@huawei.com>
>> ---
>>  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

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] crypto: marvell: Use kzfree rather than its implementation
  2019-09-04  3:01 ` [PATCH 1/3] crypto: marvell: Use kzfree rather than its implementation zhong jiang
@ 2019-09-09  7:53   ` Herbert Xu
  0 siblings, 0 replies; 7+ messages in thread
From: Herbert Xu @ 2019-09-09  7:53 UTC (permalink / raw)
  To: zhong jiang; +Cc: gregkh, arno, linux-kernel, iommu, linux-crypto, davem

On Wed, Sep 04, 2019 at 11:01:17AM +0800, zhong jiang wrote:
> Use kzfree instead of memset() + kfree().
> 
> Signed-off-by: zhong jiang <zhongjiang@huawei.com>
> ---
>  drivers/crypto/marvell/hash.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-04  3:01 [PATCH 0/3] Use kzfree instead of memset() + kfree() zhong jiang
2019-09-04  3:01 ` [PATCH 1/3] crypto: marvell: Use kzfree rather than its implementation zhong jiang
2019-09-09  7:53   ` Herbert Xu
2019-09-04  3:01 ` [PATCH 2/3] iommu/pamu: " zhong jiang
2019-09-04  8:15   ` Joerg Roedel
2019-09-04  9:38     ` zhong jiang
2019-09-04  3:01 ` [PATCH 3/3] Staging: rtl8723bs: " zhong jiang

IOMMU Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-iommu/0 linux-iommu/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-iommu linux-iommu/ https://lore.kernel.org/linux-iommu \
		iommu@lists.linux-foundation.org iommu@archiver.kernel.org
	public-inbox-index linux-iommu


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.linux-foundation.lists.iommu


AGPL code for this site: git clone https://public-inbox.org/ public-inbox