]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
target: prevent NULL pointer dereference in target_report_luns
authorJörn Engel <joern@logfs.org>
Wed, 15 Feb 2012 21:52:11 +0000 (16:52 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 2 Apr 2012 16:52:48 +0000 (09:52 -0700)
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>
drivers/target/target_core_device.c

index 097178b83b3a5bc20beb525b14dd5c2627f67450..f8773aec596579316a6cd900ec3445daef66b676 100644 (file)
@@ -658,7 +658,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