From: Ziyang Xuan <william.xuanziyang@huawei.com>
To: <jdelvare@suse.com>, <linux@roeck-us.net>,
<eajames@linux.ibm.com>, <joel@jms.id.au>, <penberg@kernel.org>,
<akpm@linux-foundation.org>, <linux-hwmon@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Cc: <william.xuanziyang@huawei.com>
Subject: [PATCH] hwmon: (occ) Delete unnecessary NULL check
Date: Mon, 6 Jun 2022 21:14:01 +0800 [thread overview]
Message-ID: <20220606131401.4053036-1-william.xuanziyang@huawei.com> (raw)
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
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;
}
--
2.25.1
next reply other threads:[~2022-06-06 12:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-06 13:14 Ziyang Xuan [this message]
2022-06-06 13:33 ` [PATCH] hwmon: (occ) Delete unnecessary NULL check Eddie James
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=20220606131401.4053036-1-william.xuanziyang@huawei.com \
--to=william.xuanziyang@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=eajames@linux.ibm.com \
--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 \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.