From aab41ff5a7d46daf9af467fba8ef8e6b058b7c36 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Tue, 20 Oct 2026 16:10:09 +0300 Subject: [PATCH] scst: Let vfree handle absent verification and copy buffers Coccinelle free/ifnullfree.cocci reports: scst/src/scst_lib.c:15441:2-7: WARNING: NULL check before some freeing functions is not needed. Remove the redundant guard around vfree(buf) in scst_copy_file and the same guard around vfree(mem_verify) in vdev_verify. Both pointers may be NULL on cleanup paths, which vfree accepts throughout the supported kernel range. Leave the NULL guards in backport.h intact: they protect older teardown APIs whose NULL handling differs, rather than these vfree calls. --- scst/src/dev_handlers/scst_vdisk_main.c | 3 +-- scst/src/scst_lib.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/scst/src/dev_handlers/scst_vdisk_main.c b/scst/src/dev_handlers/scst_vdisk_main.c index e22b93b3d..b76627118 100644 --- a/scst/src/dev_handlers/scst_vdisk_main.c +++ b/scst/src/dev_handlers/scst_vdisk_main.c @@ -2929,8 +2929,7 @@ static enum compl_status_e vdev_verify(struct scst_cmd *cmd, loff_t loff) } out_free: - if (mem_verify) - vfree(mem_verify); + vfree(mem_verify); out: TRACE_EXIT(); diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index a38442c27..359cff2bb 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -15439,8 +15439,7 @@ out_close: filp_close(file_src, NULL); out_free: - if (buf != NULL) - vfree(buf); + vfree(buf); out: TRACE_EXIT_RES(res);