lkml.org 
[lkml]   [2022]   [Jun]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] usb: core: Remove redundant NULL checks before kfree
Date
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;

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

\
 
 \ /
  Last update: 2022-06-06 03:44    [W:0.032 / U:3.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site