Commit 4c23efb4 authored by Nicholas Bellinger's avatar Nicholas Bellinger Committed by Sasha Levin

target/pscsi: Fix NULL pointer dereference in get_device_type

[ Upstream commit 215a8fe4 ]

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: default avatarOlaf Hering <olaf@aepfle.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
parent af8524b0
...@@ -1120,7 +1120,7 @@ static u32 pscsi_get_device_type(struct se_device *dev) ...@@ -1120,7 +1120,7 @@ static u32 pscsi_get_device_type(struct se_device *dev)
struct pscsi_dev_virt *pdv = PSCSI_DEV(dev); struct pscsi_dev_virt *pdv = PSCSI_DEV(dev);
struct scsi_device *sd = pdv->pdv_sd; 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) static sector_t pscsi_get_blocks(struct se_device *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment