From: Nicholas Bellinger Date: Wed, 16 Sep 2015 06:07:45 +0000 (-0700) Subject: target: Fix target_sense_desc_format NULL pointer dereference X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f3bb467ff64b2598d023b3a07592748fa7768b6a;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git target: Fix target_sense_desc_format NULL pointer dereference This patch allows target_sense_desc_format() to be called without a valid se_device pointer, which can occur during an early exception ahead of transport_lookup_cmd_lun() setting up se_cmd->se_device. This addresses a v4.3-rc1 specific NULL pointer dereference regression introduced by commit 4e4937e8. Cc: Sagi Grimberg Cc: Christoph Hellwig Cc: Hannes Reinecke Signed-off-by: Nicholas Bellinger --- diff --git a/drivers/target/target_core_hba.c b/drivers/target/target_core_hba.c index 9522960c7fdd..22390e0e046c 100644 --- a/drivers/target/target_core_hba.c +++ b/drivers/target/target_core_hba.c @@ -187,5 +187,5 @@ core_delete_hba(struct se_hba *hba) bool target_sense_desc_format(struct se_device *dev) { - return dev->transport->get_blocks(dev) > U32_MAX; + return (dev) ? dev->transport->get_blocks(dev) > U32_MAX : false; }