scsi: fix panic issue of spdk_scsi_dev_queue_task

When task->lun is NULL, spdk_scsi_dev_queue_task panics. This patch
fixes it.
This commit is contained in:
Tsuyoshi Uchida 2016-11-08 10:12:49 -08:00 committed by Daniel Verkamp
parent 987ba616fa
commit 81d60e6f30
4 changed files with 10 additions and 7 deletions

View File

@ -198,9 +198,10 @@ spdk_scsi_dev_queue_task(struct spdk_scsi_dev *dev,
{
assert(task != NULL);
/* ready to enqueue, disk is valid for LUN access */
spdk_scsi_lun_append_task(task->lun, task);
if (spdk_scsi_lun_append_task(task->lun, task) == 0) {
/* ready to execute, disk is valid for LUN access */
spdk_scsi_lun_execute_tasks(task->lun);
}
}
int

View File

@ -223,15 +223,16 @@ complete_task_with_no_lun(struct spdk_scsi_task *task)
spdk_scsi_lun_complete_task(NULL, task);
}
void
int
spdk_scsi_lun_append_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task)
{
if (lun == NULL) {
complete_task_with_no_lun(task);
return;
return -1;
}
TAILQ_INSERT_TAIL(&lun->pending_tasks, task, scsi_link);
return 0;
}
void

View File

@ -77,7 +77,7 @@ typedef struct spdk_scsi_lun _spdk_scsi_lun;
_spdk_scsi_lun *spdk_scsi_lun_construct(const char *name, struct spdk_bdev *bdev);
void spdk_scsi_lun_clear_all(struct spdk_scsi_lun *lun);
void spdk_scsi_lun_append_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task);
int spdk_scsi_lun_append_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task);
void spdk_scsi_lun_execute_tasks(struct spdk_scsi_lun *lun);
int spdk_scsi_lun_task_mgmt_execute(struct spdk_scsi_task *task);
void spdk_scsi_lun_complete_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task);

View File

@ -107,9 +107,10 @@ spdk_scsi_lun_task_mgmt_execute(struct spdk_scsi_task *task)
return 0;
}
void
int
spdk_scsi_lun_append_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task)
{
return 0;
}
void