From: Xiubo Li Date: Tue, 22 Jan 2019 10:10:51 +0000 (+0800) Subject: scsi: tcmu: fix use after free X-Git-Tag: v5.4-rc1~1561^2~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=40d883b091758472c79b81fa1c0e0347e24a9cff;p=platform%2Fkernel%2Flinux-rpi.git scsi: tcmu: fix use after free Fixes: a94a2572b977 ("scsi: tcmu: avoid cmd/qfull timers updated whenever a new cmd comes") Reported-by: Dan Carpenter Cc: Mike Christie Signed-off-by: Xiubo Li Reviewed-by: Mike Christie Signed-off-by: Martin K. Petersen --- diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index c34c88e..5831e0e 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -1317,12 +1317,13 @@ static int tcmu_check_expired_cmd(int id, void *p, void *data) * target_complete_cmd will translate this to LUN COMM FAILURE */ scsi_status = SAM_STAT_CHECK_CONDITION; + list_del_init(&cmd->queue_entry); } else { + list_del_init(&cmd->queue_entry); idr_remove(&udev->commands, id); tcmu_free_cmd(cmd); scsi_status = SAM_STAT_TASK_SET_FULL; } - list_del_init(&cmd->queue_entry); pr_debug("Timing out cmd %u on dev %s that is %s.\n", id, udev->name, is_running ? "inflight" : "queued");