Skip to contentSkip to conversation

drivers/scsi/sd.c: fix uninitialized variable in handling medium errors

PATCH In review [email protected] 1 participant 1 message Jun 9, 2006 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 2/31 drivers/scsi/sd.c: fix uninitialized variable in handling medium errors

From: Mark Lord <[email protected]>

When scsi_get_sense_info_fld() fails (returns 0), it does NOT update the value of first_err_block. But sd_rw_intr() merrily continues to use that variable regardless, possibly making incorrect decisions about retries and the like.

This patch removes the randomness there, by using the first sector of the request (SCpnt->request->sector) in such cases, instead of first_err_block.

---

 drivers/scsi/sd.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/scsi/sd.c renamed from drivers/scsi/sd.c~drivers-scsi-sdc-fix-uninitialized-variable-in-handling-medium-errors +2 -0
diff -puN drivers/scsi/sd.c~drivers-scsi-sdc-fix-uninitialized-variable-in-handling-medium-errors drivers/scsi/sd.c
@@ -959,6 +959,8 @@ static void sd_rw_intr(struct scsi_cmnd 
 			default:
 				break;
 			}
+			if (!info_valid)
+				error_sector = SCpnt->request->sector;
 
 			error_sector &= ~(block_sectors - 1);
 			good_bytes = (error_sector - SCpnt->request->sector) << 9;

_