summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2015-02-27 03:54:13 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-03-26 15:01:01 +0100
commit3bb09afbcef61767194ef3792755e38265915cd9 (patch)
tree5ecc60adfee1f692b1db15e584643fbfd1e29abc
parent2078161617e32d457414cd9accabe33909142b90 (diff)
downloadlinux-stable-3bb09afbcef61767194ef3792755e38265915cd9.tar.gz
linux-stable-3bb09afbcef61767194ef3792755e38265915cd9.tar.bz2
linux-stable-3bb09afbcef61767194ef3792755e38265915cd9.zip
target/pscsi: Fix NULL pointer dereference in get_device_type
commit 215a8fe4198f607f34ecdbc9969dae783d8b5a61 upstream. This patch fixes a NULL pointer dereference OOPs with pSCSI backends within target_core_stat.c code. The bug is caused by a configfs attr read if no pscsi_dev_virt->pdv_sd has been configured. Reported-by: Olaf Hering <olaf@aepfle.de> 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_pscsi.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index 3250ba2594e0..b1e77ff9a636 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -1112,7 +1112,7 @@ static u32 pscsi_get_device_type(struct se_device *dev)
struct pscsi_dev_virt *pdv = PSCSI_DEV(dev);
struct scsi_device *sd = pdv->pdv_sd;
- return sd->type;
+ return (sd) ? sd->type : TYPE_NO_LUN;
}
static sector_t pscsi_get_blocks(struct se_device *dev)