>From c6645f639f7e7551c7a6f0aacee78e57ddd37bc1 Mon Sep 17 00:00:00 2001 From: Joe Lawrence <joe.lawrence@xxxxxxxxxxx> Date: Tue, 28 May 2013 14:49:37 -0400 Subject: [PATCH 1/2] scsi_dh_emc: handle zero-senselen send_inquiry_cmd errors The send_inquiry_cmd function may exit without setting senselen if get_req fails. Callers shouldn't assume senselen is set non-zero in their failure checking. Signed-off-by: Joe Lawrence <joe.lawrence@xxxxxxxxxxx> Cc: "James E.J. Bottomley" <JBottomley@xxxxxxxxxxxxx> Cc: Hannes Reinecke <hare@xxxxxxx> Cc: Mike Christie <michaelc@xxxxxxxxxxx> --- drivers/scsi/device_handler/scsi_dh_emc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh_emc.c b/drivers/scsi/device_handler/scsi_dh_emc.c index e1c8be0..0438ed6 100644 --- a/drivers/scsi/device_handler/scsi_dh_emc.c +++ b/drivers/scsi/device_handler/scsi_dh_emc.c @@ -468,9 +468,12 @@ static int clariion_std_inquiry(struct scsi_device *sdev, char *sp_model; err = send_inquiry_cmd(sdev, 0, csdev); - if (err != SCSI_DH_OK && csdev->senselen) { + if (err != SCSI_DH_OK) { struct scsi_sense_hdr sshdr; + if (!csdev->senselen) + goto out; + if (scsi_normalize_sense(csdev->sense, SCSI_SENSE_BUFFERSIZE, &sshdr)) { sdev_printk(KERN_ERR, sdev, "%s: INQUIRY sense code " @@ -507,9 +510,12 @@ static int clariion_send_inquiry(struct scsi_device *sdev, retry: err = send_inquiry_cmd(sdev, 0xC0, csdev); - if (err != SCSI_DH_OK && csdev->senselen) { + if (err != SCSI_DH_OK) { struct scsi_sense_hdr sshdr; + if (!csdev->senselen) + goto out; + err = scsi_normalize_sense(csdev->sense, SCSI_SENSE_BUFFERSIZE, &sshdr); if (!err) @@ -527,6 +533,7 @@ retry: } else { err = parse_sp_info_reply(sdev, csdev); } +out: return err; } -- 1.7.10.4 -- 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