diff options
author | Roland Dreier <roland@purestorage.com> | 2014-10-14 14:16:24 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-12-06 15:57:29 -0800 |
commit | f627a34869c287134b88879d8ce1bc1d542f73a5 (patch) | |
tree | f7cc3ec36e76510625c433a40c0048b7c80cff55 | |
parent | 674d238eaee130a0686d06cbcd16e045de925420 (diff) | |
download | linux-stable-f627a34869c287134b88879d8ce1bc1d542f73a5.tar.gz linux-stable-f627a34869c287134b88879d8ce1bc1d542f73a5.tar.bz2 linux-stable-f627a34869c287134b88879d8ce1bc1d542f73a5.zip |
target: Don't call TFO->write_pending if data_length == 0
commit 885e7b0e181c14e4d0ddd26c688bad2b84c1ada9 upstream.
If an initiator sends a zero-length command (e.g. TEST UNIT READY) but
sets the transfer direction in the transport layer to indicate a
data-out phase, we still shouldn't try to transfer data. At best it's
a NOP, and depending on the transport, we might crash on an
uninitialized sg list.
Reported-by: Craig Watson <craig.watson@vanguard-rugged.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/target/target_core_transport.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index ab610146681d..a9c77b5116e3 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -2295,7 +2295,7 @@ transport_generic_new_cmd(struct se_cmd *cmd) * and let it call back once the write buffers are ready. */ target_add_to_state_list(cmd); - if (cmd->data_direction != DMA_TO_DEVICE) { + if (cmd->data_direction != DMA_TO_DEVICE || cmd->data_length == 0) { target_execute_cmd(cmd); return 0; } |