From: Andrey Vatoropin Date: Tue, 18 Nov 2025 08:42:31 +0000 (+0000) Subject: scsi: target: Reset t_task_cdb pointer in error case X-Git-Tag: v5.10.248~207 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6cac97b12bdab04832e0416d049efcd0d48d303b;p=thirdparty%2Fkernel%2Fstable.git scsi: target: Reset t_task_cdb pointer in error case commit 5053eab38a4c4543522d0c320c639c56a8b59908 upstream. If allocation of cmd->t_task_cdb fails, it remains NULL but is later dereferenced in the 'err' path. In case of error, reset NULL t_task_cdb value to point at the default fixed-size buffer. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 9e95fb805dc0 ("scsi: target: Fix NULL pointer dereference") Cc: stable@vger.kernel.org Signed-off-by: Andrey Vatoropin Reviewed-by: Mike Christie Link: https://patch.msgid.link/20251118084014.324940-1-a.vatoropin@crpt.ru Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 8d294b658592c..ddcfd5c17d96e 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1449,6 +1449,7 @@ target_cmd_init_cdb(struct se_cmd *cmd, unsigned char *cdb) cmd->t_task_cdb = kzalloc(scsi_command_size(cdb), GFP_KERNEL); if (!cmd->t_task_cdb) { + cmd->t_task_cdb = &cmd->__t_task_cdb[0]; pr_err("Unable to allocate cmd->t_task_cdb" " %u > sizeof(cmd->__t_task_cdb): %lu ops\n", scsi_command_size(cdb),