linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] usb: core: Remove redundant NULL checks before kfree
@ 2022-06-13  1:31 cgel.zte
  2022-06-21 14:32 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2022-06-13  1:31 UTC (permalink / raw)
  To: gregkh; +Cc: olebowle, linux-usb, linux-kernel, Minghao Chi, Zeal Robot

From: Minghao Chi <chi.minghao@zte.com.cn>

Checking a pointer for NULL before calling kfree() on it is redundant,
kfree() deals with NULL pointers just fine.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
---
v1->v2:
	remove "quirk_list = NULL"
 drivers/usb/core/quirks.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index f99a65a64588..9ec12c42db30 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -56,10 +56,7 @@ static int quirks_param_set(const char *value, const
struct kernel_param *kp)
 		if (val[i] == ',')
 			quirk_count++;
 
-	if (quirk_list) {
-		kfree(quirk_list);
-		quirk_list = NULL;
-	}
+	kfree(quirk_list);
 
 	quirk_list = kcalloc(quirk_count, sizeof(struct quirk_entry),
 			     GFP_KERNEL);
-- 
2.25.1


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

* Re: [PATCH V2] usb: core: Remove redundant NULL checks before kfree
  2022-06-13  1:31 [PATCH V2] usb: core: Remove redundant NULL checks before kfree cgel.zte
@ 2022-06-21 14:32 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2022-06-21 14:32 UTC (permalink / raw)
  To: cgel.zte; +Cc: olebowle, linux-usb, linux-kernel, Minghao Chi, Zeal Robot

On Mon, Jun 13, 2022 at 01:31:16AM +0000, cgel.zte@gmail.com wrote:
> From: Minghao Chi <chi.minghao@zte.com.cn>
> 
> Checking a pointer for NULL before calling kfree() on it is redundant,
> kfree() deals with NULL pointers just fine.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
> ---
> v1->v2:
> 	remove "quirk_list = NULL"
>  drivers/usb/core/quirks.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
> index f99a65a64588..9ec12c42db30 100644
> --- a/drivers/usb/core/quirks.c
> +++ b/drivers/usb/core/quirks.c
> @@ -56,10 +56,7 @@ static int quirks_param_set(const char *value, const
> struct kernel_param *kp)
>  		if (val[i] == ',')
>  			quirk_count++;
>  
> -	if (quirk_list) {
> -		kfree(quirk_list);
> -		quirk_list = NULL;
> -	}
> +	kfree(quirk_list);
>  
>  	quirk_list = kcalloc(quirk_count, sizeof(struct quirk_entry),
>  			     GFP_KERNEL);
> -- 
> 2.25.1
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch is malformed (tabs converted to spaces, linewrapped, etc.)
  and can not be applied.  Please read the file,
  Documentation/email-clients.txt in order to fix this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

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

end of thread, other threads:[~2022-06-21 14:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-13  1:31 [PATCH V2] usb: core: Remove redundant NULL checks before kfree cgel.zte
2022-06-21 14:32 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).