lkml.org 
[lkml]   [2015]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] SCSI: sd: fix null dereference
Date
we were dereferencing sdkp first and then we were checking for it
being NULL.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.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


\
 
 \ /
  Last update: 2015-03-07 07:01    [W:1.276 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site