CC: [email protected]
TO: John Ogness <[email protected]>
CC: Sebastian Andrzej Siewior <[email protected]>
CC: Petr Mladek <[email protected]>
CC: Sergey Senozhatsky <[email protected]>
CC: Steven Rostedt <[email protected]>
CC: [email protected]

From: kernel test robot <[email protected]>

kernel/printk/printk.c:1699:2-7: WARNING: NULL check before some freeing 
functions is not needed.
kernel/printk/printk.c:1701:2-7: WARNING: NULL check before some freeing 
functions is not needed.
kernel/printk/printk.c:1543:2-7: WARNING: NULL check before some freeing 
functions is not needed.
kernel/printk/printk.c:1545:2-7: WARNING: NULL check before some freeing 
functions is not needed.

 NULL check before some freeing functions is not needed.

 Based on checkpatch warning
 "kfree(NULL) is safe this check is probably not required"
 and kfreeaddr.cocci by Julia Lawall.

Generated by: scripts/coccinelle/free/ifnullfree.cocci

Fixes: c406fbce2054 ("printk: implement syslog")
CC: John Ogness <[email protected]>
Signed-off-by: kernel test robot <[email protected]>
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git 
linux-5.4.y-rt
head:   5fbf1e70f11dba64cc05c9d85120a3aa7c67a4a2
commit: c406fbce2054efbf812b3d811ed23a872f719db9 [43/325] printk: implement 
syslog
:::::: branch date: 6 months ago
:::::: commit date: 10 months ago

Please take the patch only if it's a positive warning. Thanks!

 printk.c |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1539,10 +1539,8 @@ static int syslog_print_all(char __user
        if (clear && !seq)
                syslog_clear();
 
-       if (text)
-               kfree(text);
-       if (msgbuf)
-               kfree(msgbuf);
+       kfree(text);
+       kfree(msgbuf);
        return len;
 }
 
@@ -1695,10 +1693,8 @@ int do_syslog(int type, char __user *buf
                break;
        }
 out:
-       if (msgbuf)
-               kfree(msgbuf);
-       if (text)
-               kfree(text);
+       kfree(msgbuf);
+       kfree(text);
        return error;
 }
 
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to