Skip to content

Commit 40d883b

Browse files
lxbszmartinkpetersen
authored andcommitted
scsi: tcmu: fix use after free
Fixes: a94a257 ("scsi: tcmu: avoid cmd/qfull timers updated whenever a new cmd comes") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: Mike Christie <mchristi@redhat.com> Signed-off-by: Xiubo Li <xiubli@redhat.com> Reviewed-by: Mike Christie <mchristi@redhat.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent fe35a40 commit 40d883b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/target/target_core_user.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,12 +1317,13 @@ static int tcmu_check_expired_cmd(int id, void *p, void *data)
13171317
* target_complete_cmd will translate this to LUN COMM FAILURE
13181318
*/
13191319
scsi_status = SAM_STAT_CHECK_CONDITION;
1320+
list_del_init(&cmd->queue_entry);
13201321
} else {
1322+
list_del_init(&cmd->queue_entry);
13211323
idr_remove(&udev->commands, id);
13221324
tcmu_free_cmd(cmd);
13231325
scsi_status = SAM_STAT_TASK_SET_FULL;
13241326
}
1325-
list_del_init(&cmd->queue_entry);
13261327

13271328
pr_debug("Timing out cmd %u on dev %s that is %s.\n",
13281329
id, udev->name, is_running ? "inflight" : "queued");

0 commit comments

Comments
 (0)