mirror of
https://github.com/SCST-project/scst.git
synced 2026-08-20 22:26:23 +00:00
scst: Fix scst_set_lun_not_supported_inquiry()
Avoid that the call stack below is triggered when an INQUIRY is sent to an scst_local LUN that does not exist. [2990]: scst: scst_set_resp_data_len:2870:***ERROR***: Too big response data len 36 (max 0), limiting it to the max (dev (no LUN)) Pid: 2990, comm: kworker/u:3 Tainted: G O 3.9.0-rc4-debug+ #1 Call Trace: [<ffffffffa027cac1>] scst_set_resp_data_len+0x1b1/0x1d0 [scst] [<ffffffffa027ef20>] scst_set_lun_not_supported_inquiry+0x140/0x400 [scst] [<ffffffff81080f05>] ? sched_clock_local+0x25/0x90 [<ffffffffa027f2cf>] scst_set_cmd_error+0xef/0x210 [scst] [<ffffffffa02650f5>] ? scst_translate_lun+0x125/0x320 [scst] [<ffffffffa026fd10>] __scst_init_cmd+0x1f0/0x270 [scst] [<ffffffffa027015b>] scst_init_cmd+0x6b/0x310 [scst] [<ffffffffa0273b94>] scst_cmd_init_done+0x124/0x5b0 [scst] [<ffffffffa026dcb8>] ? scst_rx_cmd+0xb8/0x220 [scst] [<ffffffff81081098>] ? sched_clock_cpu+0xa8/0x110 [<ffffffffa02f3b5e>] scst_local_queuecommand+0x1ae/0x3c0 [scst_local] [<ffffffff8133870f>] ? scsi_request_fn+0x34f/0x530 [<ffffffff81531de0>] ? _raw_spin_unlock_irq+0x30/0x50 [<ffffffff81331320>] scsi_dispatch_cmd+0x150/0x4b0 [<ffffffff81338721>] scsi_request_fn+0x361/0x530 [<ffffffff8121be37>] __blk_run_queue+0x37/0x50 [<ffffffff812294b1>] blk_execute_rq_nowait+0x81/0x100 [<ffffffff8106cc46>] ? __init_waitqueue_head+0x46/0x60 [<ffffffff81229682>] blk_execute_rq+0x152/0x200 [<ffffffff811adb41>] ? bio_phys_segments+0x21/0x30 [<ffffffff812243f0>] ? blk_rq_bio_prep+0x30/0xb0 [<ffffffff81337de6>] scsi_execute+0xe6/0x180 [<ffffffff81338fbd>] scsi_execute_req+0xbd/0x130 [<ffffffff8133ace7>] scsi_probe_and_add_lun+0x257/0xe10 [<ffffffff8152b18e>] ? __slab_free+0x2c0/0x311 [<ffffffff8133c113>] __scsi_scan_target+0x2a3/0x790 [<ffffffff8131fd09>] ? __pm_runtime_resume+0x69/0xa0 [<ffffffff81531e3f>] ? _raw_spin_unlock_irqrestore+0x3f/0x80 [<ffffffff8133c78e>] scsi_scan_target+0xfe/0x110 [<ffffffffa02f281c>] scst_process_aens+0xcc/0x210 [scst_local] [<ffffffff815317f2>] ? _raw_spin_lock+0x72/0x80 [<ffffffffa02f2669>] ? spin_lock+0x9/0x10 [scst_local] [<ffffffffa02f2b39>] scst_aen_work_fn+0x79/0x140 [scst_local] [<ffffffff810655ca>] process_one_work+0x1da/0x650 [<ffffffff81065562>] ? process_one_work+0x172/0x650 [<ffffffff81065df2>] worker_thread+0x112/0x330 [<ffffffff81065ce0>] ? rescuer_thread+0x260/0x260 [<ffffffff8106c15d>] kthread+0xed/0x100 [<ffffffff810a0d75>] ? lock_release_holdtime.part.26+0x15/0x1a0 [<ffffffff8106c070>] ? flush_kthread_worker+0x190/0x190 [<ffffffff8153b92c>] ret_from_fork+0x7c/0xb0 [<ffffffff8106c070>] ? flush_kthread_worker+0x190/0x190 Signed-off-by: Bart Van Assche <bvanassche@acm.org> git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4837 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
+3
-3
@@ -1544,6 +1544,9 @@ static int scst_set_lun_not_supported_inquiry(struct scst_cmd *cmd)
|
||||
}
|
||||
|
||||
if (cmd->sg == NULL) {
|
||||
if (cmd->bufflen == 0)
|
||||
cmd->bufflen = min_t(int, 36, get_unaligned_be16(&cmd->cdb[3]));
|
||||
|
||||
/*
|
||||
* If target driver preparing data buffer using tgt_alloc_data_buf()
|
||||
* callback, it is responsible to copy the sense to its buffer
|
||||
@@ -1557,9 +1560,6 @@ static int scst_set_lun_not_supported_inquiry(struct scst_cmd *cmd)
|
||||
goto go;
|
||||
}
|
||||
|
||||
if (cmd->bufflen == 0)
|
||||
cmd->bufflen = min_t(int, 36, get_unaligned_be16(&cmd->cdb[3]));
|
||||
|
||||
cmd->sg = scst_alloc_sg(cmd->bufflen, GFP_ATOMIC, &cmd->sg_cnt);
|
||||
if (cmd->sg == NULL) {
|
||||
PRINT_ERROR("%s", "Unable to alloc sg for INQUIRY "
|
||||
|
||||
Reference in New Issue
Block a user