Skip to contentSkip to conversation

smb/client: remove redundant NULL check before kfree()

PATCH Applied Huiwen He 3 participants 4 messages Aug 16 – Aug 21

Subsystems (2)
lore
Share & tools
lore

Huiwen He

author
#0 lore raw

PATCH 1/1 smb/client: remove redundant NULL check before kfree()

From: Huiwen He <[email protected]>

kfree() accepts NULL pointers, so checking tmp_cfile before freeing it is unnecessary and triggers a Coccinelle warning.

Remove the redundant check. This does not change runtime behavior.

Fixes 5693347de107 ("smb/client: use writable handle for FS_IOC_SETFLAGS compression")
---
 fs/smb/client/ioctl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/smb/client/ioctl.c +1 -2
index 9fa743be3652..2f152d76be7d 100644
@@ -133,8 +133,7 @@ static int cifs_set_compression_by_path(unsigned int xid, struct file *filep,
 
 close:
 	server->ops->close(xid, tcon, &fid);
-	if (tmp_cfile)
-		kfree(tmp_cfile);
+	kfree(tmp_cfile);
 	cifs_free_open_info(&data);
 out:
 	free_dentry_path(page);
Signature · 1 line
2.43.0
maintainer Applied
#1 lore raw
Quoted 6 lines · Huiwen He

From: Huiwen He <[email protected]>

kfree() accepts NULL pointers, so checking tmp_cfile before freeing it is unnecessary and triggers a Coccinelle warning.

Quoted 6 lines

Remove the redundant check. This does not change runtime behavior.

Fixes 5693347de107 ("smb/client: use writable handle for FS_IOC_SETFLAGS compression")

Applied it to #for-next.
Thanks!

author
#2 lore raw

Hi Namjae,

I copied the Fixes, Reported-by, and Closes tags from the kernel test robot report when sending the patch.

Quoted 7 lines
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   3eb40771c00a8488fa6ed2cc1fe203477908bf38
commit: 5693347de107a26f68d1f43b25ff2e348c7229a9 smb/client: use writable handle for FS_IOC_SETFLAGS compression
date:   9 weeks ago
config: powerpc-randconfig-r053-20260812 (https://download.01.org/0day-ci/archive/20260816/[email protected]/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 12df34b8469b8095359de8c249cb1b2753fadeea)
Quoted 8 lines

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags

| Fixes: 5693347de107 ("smb/client: use writable handle for FS_IOC_SETFLAGS compression")
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

cocci warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

fs/smb/client/ioctl.c:135:2-7: WARNING: NULL check before some freeing functions is not needed.

But chenxiaosong suggested that the Fixes tag may not be necessary because this is only a Coccinelle cleanup with no functional change. I am not sure which convention is preferred here, so please feel free to
drop the Fixes tag when applying the patch.

Thanks,
Huiwen

Quoted 15 lines · Namjae Jeon
Quoted 6 lines · Huiwen He

From: Huiwen He <[email protected]>

kfree() accepts NULL pointers, so checking tmp_cfile before freeing it is unnecessary and triggers a Coccinelle warning.

Quoted 6 lines

Remove the redundant check. This does not change runtime behavior.

Fixes 5693347de107 ("smb/client: use writable handle for FS_IOC_SETFLAGS compression")

Applied it to #for-next.
Thanks!