Skip to content

Commit 5053eab

Browse files
Andrey Vatoropinmartinkpetersen
authored andcommitted
scsi: target: Reset t_task_cdb pointer in error case
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: 9e95fb8 ("scsi: target: Fix NULL pointer dereference") Cc: stable@vger.kernel.org Signed-off-by: Andrey Vatoropin <a.vatoropin@crpt.ru> Reviewed-by: Mike Christie <michael.christie@oracle.com> Link: https://patch.msgid.link/20251118084014.324940-1-a.vatoropin@crpt.ru Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent b4bb6da commit 5053eab

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

drivers/target/target_core_transport.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,7 @@ target_cmd_init_cdb(struct se_cmd *cmd, unsigned char *cdb, gfp_t gfp)
15241524
if (scsi_command_size(cdb) > sizeof(cmd->__t_task_cdb)) {
15251525
cmd->t_task_cdb = kzalloc(scsi_command_size(cdb), gfp);
15261526
if (!cmd->t_task_cdb) {
1527+
cmd->t_task_cdb = &cmd->__t_task_cdb[0];
15271528
pr_err("Unable to allocate cmd->t_task_cdb"
15281529
" %u > sizeof(cmd->__t_task_cdb): %lu ops\n",
15291530
scsi_command_size(cdb),

0 commit comments

Comments
 (0)