diff options
author | Jörn Engel <joern@logfs.org> | 2012-02-15 16:52:11 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-04-02 10:32:02 -0700 |
commit | 3b5e7a259c88befb754607dcabd14b4f01bef212 (patch) | |
tree | d8a504a5291bbf776e35ca737498a862db7fbbfc | |
parent | 1459484eea1cb844a9977b6fe49009dd2668c44a (diff) |
target: prevent NULL pointer dereference in target_report_luns
commit 47f1b8803e1e358ebbf4f82bfdb98971c912a2c3 upstream.
transport_kmap_data_sg can return NULL. I never saw this trigger, but
returning -ENOMEM seems better than a crash. Also removes a pointless
case while at it.
Signed-off-by: Joern Engel <joern@logfs.org>
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_device.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index b013437679cd..ce6400d65ba5 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -657,7 +657,9 @@ int target_report_luns(struct se_task *se_task) unsigned char *buf; u32 cdb_offset = 0, lun_count = 0, offset = 8, i; - buf = (unsigned char *) transport_kmap_data_sg(se_cmd); + buf = transport_kmap_data_sg(se_cmd); + if (!buf) + return -ENOMEM; /* * If no struct se_session pointer is present, this struct se_cmd is |