mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eddie James <eajames@linux.ibm.com>
To: Ziyang Xuan <william.xuanziyang@huawei.com>,
	jdelvare@suse.com, linux@roeck-us.net, joel@jms.id.au,
	penberg@kernel.org, akpm@linux-foundation.org,
	linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hwmon: (occ) Delete unnecessary NULL check
Date: Mon, 6 Jun 2022 08:33:24 -0500	[thread overview]
Message-ID: <bc88300d-9321-e4f6-4215-1754fa3a0444@linux.ibm.com> (raw)
In-Reply-To: <20220606131401.4053036-1-william.xuanziyang@huawei.com>


On 6/6/22 08:14, Ziyang Xuan wrote:
> kvfree(NULL) is safe. NULL check before kvfree() is not needed.
> Delete them to simplify the code.
>
> Generated by coccinelle script:
> 	scripts/coccinelle/free/ifnullfree.cocci


Thanks for the patch!

Reviewed-by: Eddie James <eajames@linux.ibm.com>


>
> Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
> ---
>   drivers/hwmon/occ/p9_sbe.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hwmon/occ/p9_sbe.c b/drivers/hwmon/occ/p9_sbe.c
> index 42fc7b97bb34..01405ae2f9bd 100644
> --- a/drivers/hwmon/occ/p9_sbe.c
> +++ b/drivers/hwmon/occ/p9_sbe.c
> @@ -55,8 +55,7 @@ static bool p9_sbe_occ_save_ffdc(struct p9_sbe_occ *ctx, const void *resp,
>   	mutex_lock(&ctx->sbe_error_lock);
>   	if (!ctx->sbe_error) {
>   		if (resp_len > ctx->ffdc_size) {
> -			if (ctx->ffdc)
> -				kvfree(ctx->ffdc);
> +			kvfree(ctx->ffdc);
>   			ctx->ffdc = kvmalloc(resp_len, GFP_KERNEL);
>   			if (!ctx->ffdc) {
>   				ctx->ffdc_len = 0;
> @@ -171,8 +170,7 @@ static int p9_sbe_occ_remove(struct platform_device *pdev)
>   	ctx->sbe = NULL;
>   	occ_shutdown(occ);
>   
> -	if (ctx->ffdc)
> -		kvfree(ctx->ffdc);
> +	kvfree(ctx->ffdc);
>   
>   	return 0;
>   }

  reply	other threads:[~2022-06-06 13:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-06 13:14 Ziyang Xuan
2022-06-06 13:33 ` Eddie James [this message]
2022-06-06 14:19 Guenter Roeck

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=bc88300d-9321-e4f6-4215-1754fa3a0444@linux.ibm.com \
    --to=eajames@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=jdelvare@suse.com \
    --cc=joel@jms.id.au \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=penberg@kernel.org \
    --cc=william.xuanziyang@huawei.com \
    /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®