mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
scsi: target: Reset t_task_cdb pointer in error case
commit5053eab38aupstream. 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:9e95fb805d("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
8c5ce5fafe
commit
8edbb9e371
@@ -1524,6 +1524,7 @@ target_cmd_init_cdb(struct se_cmd *cmd, unsigned char *cdb, gfp_t gfp)
|
||||
if (scsi_command_size(cdb) > sizeof(cmd->__t_task_cdb)) {
|
||||
cmd->t_task_cdb = kzalloc(scsi_command_size(cdb), gfp);
|
||||
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),
|
||||
|
||||
Reference in New Issue
Block a user