summaryrefslogtreecommitdiff
path: root/drivers/target
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2015-02-27 14:54:13 +0300
committerZefan Li <lizefan@huawei.com>2015-06-19 06:40:28 +0300
commit444edcfc0bd195209594087dbe78a5dc8ef962b0 (patch)
treeea181c6b5cf3b4ea28045a41dc77a69b8055510a /drivers/target
parentcac6fdb55e69d678a38cfdcb89412bcb66e4a665 (diff)
downloadlinux-444edcfc0bd195209594087dbe78a5dc8ef962b0.tar.xz
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: Zefan Li <lizefan@huawei.com>
Diffstat (limited to 'drivers/target')
-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 d34577dbfd25..808267456eed 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -1165,7 +1165,7 @@ static u32 pscsi_get_device_type(struct se_device *dev)
struct pscsi_dev_virt *pdv = dev->dev_ptr;
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)