lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Sat,  7 Mar 2015 11:17:34 +0530
From:	Sudip Mukherjee <sudipm.mukherjee@...il.com>
To:	"James E.J. Bottomley" <JBottomley@...allels.com>
Cc:	Sudip Mukherjee <sudipm.mukherjee@...il.com>,
	linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] SCSI: sd: fix null dereference

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

Signed-off-by: Sudip Mukherjee <sudip@...torindia.org>
---
 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-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ