target/pscsi: Fix NULL pointer dereference in get_device_type
authorNicholas Bellinger <nab@linux-iscsi.org>
Fri, 27 Feb 2015 11:54:13 +0000 (03:54 -0800)
committerNicholas Bellinger <nab@linux-iscsi.org>
Fri, 20 Mar 2015 06:26:42 +0000 (23:26 -0700)
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>
Cc: <stable@vger.kernel.org>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_pscsi.c

index 1045dcd7bf651b679ee355a19401065d559976b1..f6c954c4635f5dab27ac24ea117dd284561c836a 100644 (file)
@@ -1121,7 +1121,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)