[PATCH] SCSI: sd: fix null dereference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



we were dereferencing sdkp first and then we were checking for it
being NULL. 

Signed-off-by: Sudip Mukherjee <sudip@xxxxxxxxxxxxxxx>
---
 drivers/scsi/sd_dif.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/sd_dif.c b/drivers/scsi/sd_dif.c
index 14c7d42..a514645 100644
--- a/drivers/scsi/sd_dif.c
+++ b/drivers/scsi/sd_dif.c
@@ -40,11 +40,16 @@
  */
 void sd_dif_config_host(struct scsi_disk *sdkp)
 {
-	struct scsi_device *sdp = sdkp->device;
-	struct gendisk *disk = sdkp->disk;
-	u8 type = sdkp->protection_type;
+	struct scsi_device *sdp = NULL;
+	struct gendisk *disk = NULL;
+	u8 type;
 	int dif, dix;
 
+	if (!sdkp)
+		return;
+	sdp = sdkp->device;
+	disk = sdkp->disk;
+	type = sdkp->protection_type;
 	dif = scsi_host_dif_capable(sdp->host, type);
 	dix = scsi_host_dix_capable(sdp->host, type);
 
@@ -77,9 +82,6 @@ void sd_dif_config_host(struct scsi_disk *sdkp)
 
 		disk->integrity->flags |= BLK_INTEGRITY_DEVICE_CAPABLE;
 
-		if (!sdkp)
-			return;
-
 		if (type == SD_DIF_TYPE3_PROTECTION)
 			disk->integrity->tag_size = sizeof(u16) + sizeof(u32);
 		else
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux