mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: cgel.zte@gmail.com
Cc: oneukum@suse.com, olebowle@gmx.com, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Minghao Chi <chi.minghao@zte.com.cn>,
	Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH] usb: core: Remove redundant NULL checks before kfree
Date: Fri, 10 Jun 2022 11:06:12 +0200	[thread overview]
Message-ID: <YqMJhNr1noPX92Yz@kroah.com> (raw)
In-Reply-To: <20220606014352.290600-1-chi.minghao@zte.com.cn>

On Mon, Jun 06, 2022 at 01:43:52AM +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>
> ---
>  drivers/usb/core/quirks.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
> index f99a65a64588..7e918e4a95f2 100644
> --- a/drivers/usb/core/quirks.c
> +++ b/drivers/usb/core/quirks.c
> @@ -56,10 +56,8 @@ 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 = NULL;

Why are you setting this to NULL right before you assign it again:

>  	quirk_list = kcalloc(quirk_count, sizeof(struct quirk_entry),
>  			     GFP_KERNEL);

Please just free and move on.

thanks,

greg k-h

      reply	other threads:[~2022-06-10  9:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-06  1:43 cgel.zte
2022-06-10  9:06 ` Greg KH [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YqMJhNr1noPX92Yz@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=cgel.zte@gmail.com \
    --cc=chi.minghao@zte.com.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=olebowle@gmx.com \
    --cc=oneukum@suse.com \
    --cc=zealci@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®