* [PATCH] SCSI: sd: fix null dereference
@ 2015-03-07 5:47 Sudip Mukherjee
2015-03-07 13:46 ` Martin K. Petersen
0 siblings, 1 reply; 2+ messages in thread
From: Sudip Mukherjee @ 2015-03-07 5:47 UTC (permalink / raw)
To: James E.J. Bottomley; +Cc: Sudip Mukherjee, linux-scsi, linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] SCSI: sd: fix null dereference
2015-03-07 5:47 [PATCH] SCSI: sd: fix null dereference Sudip Mukherjee
@ 2015-03-07 13:46 ` Martin K. Petersen
0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2015-03-07 13:46 UTC (permalink / raw)
To: Sudip Mukherjee; +Cc: James E.J. Bottomley, linux-scsi, linux-kernel
>>>>> "Sudip" == Sudip Mukherjee <sudipm.mukherjee@gmail.com> writes:
Sudip> we were dereferencing sdkp first and then we were checking for it
Sudip> being NULL.
http://marc.info/?l=linux-kernel&m=142564395705827&w=2
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-07 13:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-07 5:47 [PATCH] SCSI: sd: fix null dereference Sudip Mukherjee
2015-03-07 13:46 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome