Skip to content

Commit

Permalink
target: prevent NULL pointer dereference in target_report_luns
Browse files Browse the repository at this point in the history
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>
Cc: stable@vger.kernel.org
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
  • Loading branch information
Jörn Engel authored and Nicholas Bellinger committed Feb 25, 2012
1 parent 382436f commit 47f1b88
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/target/target_core_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,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
Expand Down

0 comments on commit 47f1b88

Please sign in to comment.