target: support zero-size allocation lengths in transport_kmap_data_sg
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 7 Sep 2012 15:30:35 +0000 (17:30 +0200)
committerNicholas Bellinger <nab@linux-iscsi.org>
Fri, 7 Sep 2012 18:10:32 +0000 (11:10 -0700)
commit3717ef0c63e90686d959158e9728a13a49229be6
tree2533871c52a5b22e1471443f972850afcfe480b6
parent9b16b9edb4fd0dc86ee0fbe1f7ede580e26e85f4
target: support zero-size allocation lengths in transport_kmap_data_sg

In order to support zero-size allocation lengths, do not assert
that we have a scatterlist until after checking cmd->data_length.

But once we do this, we can have two cases of transport_kmap_data_sg
returning NULL: a zero-size allocation length, or an out-of-memory
condition.  Report the latter using sense codes, so that the SCSI
command that triggered it will fail.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_transport.c