Skip to contentSkip to conversation

hpsa: fix bad comparison of signed with unsigned in hpsa_update_scsi_devices

PATCH New Stephen M. Cameron 1 participant 3 messages May 21, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 hpsa: fix bad comparison of signed with unsigned in hpsa_update_scsi_devices

From: Joe Handzik <[email protected]>

rescan_hba_mode was defined as a u8 so could never be less than zero:

        rescan_hba_mode = hpsa_hba_mode_enabled(h);
        if (rescan_hba_mode < 0)
                goto out;
---
 drivers/scsi/hpsa.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/hpsa.c +1 -1
index 654e341..c5b24e6 100644
@@ -3010,7 +3010,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 	int reportlunsize = sizeof(*physdev_list) + HPSA_MAX_PHYS_LUN * 24;
 	int i, n_ext_target_devs, ndevs_to_allocate;
 	int raid_ctlr_position;
-	u8 rescan_hba_mode;
+	int rescan_hba_mode;
 	DECLARE_BITMAP(lunzerobits, MAX_EXT_TARGETS);
 
 	currentsd = kzalloc(sizeof(*currentsd) * HPSA_MAX_DEVICES, GFP_KERNEL);
#1 lore raw

PATCH 2/3 hpsa: return -ENOMEM not -1 on kzalloc failure in hpsa_get_device_id

From: Stephen M. Cameron <[email protected]>

---
 drivers/scsi/hpsa.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/hpsa.c +1 -1
index c5b24e6..af51e7d 100644
@@ -2430,7 +2430,7 @@ static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr,
 		buflen = 16;
 	buf = kzalloc(64, GFP_KERNEL);
 	if (!buf)
-		return -1;
+		return -ENOMEM;
 	rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | 0x83, buf, 64);
 	if (rc == 0)
 		memcpy(device_id, &buf[8], buflen);
#2 lore raw

PATCH 3/3 hpsa: fix handling of hpsa_volume_offline return value

In reply to Stephen M. Cameron

From: Stephen M. Cameron <[email protected]>

Make return value an int instead of an unsigned char so that we do not lose negative error return values.

---
 drivers/scsi/hpsa.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/hpsa.c +3 -3
index af51e7d..13ec036 100644
@@ -1191,7 +1191,7 @@ static void hpsa_monitor_offline_device(struct ctlr_info *h,
 static void hpsa_show_volume_status(struct ctlr_info *h,
 	struct hpsa_scsi_dev_t *sd)
 {
-	if (sd->volume_offline == HPSA_VPD_LV_STATUS_UNSUPPORTED)
+	if (sd->volume_offline == (u8) HPSA_VPD_LV_STATUS_UNSUPPORTED)
 		dev_info(&h->pdev->dev,
 			"C%d:B%d:T%d:L%d Volume status is not available through vital product data pages.\n",
 			h->scsi_host->host_no,
@@ -2547,7 +2547,7 @@ exit_failed:
  *  # (integer code indicating one of several NOT READY states
  *     describing why a volume is to be kept offline)
  */
-static unsigned char hpsa_volume_offline(struct ctlr_info *h,
+static int hpsa_volume_offline(struct ctlr_info *h,
 					unsigned char scsi3addr[])
 {
 	struct CommandList *c;
@@ -2650,7 +2650,7 @@ static int hpsa_update_device_info(struct ctlr_info *h,
 		if (h->fw_support & MISC_FW_RAID_OFFLOAD_BASIC)
 			hpsa_get_ioaccel_status(h, scsi3addr, this_device);
 		this_device->volume_offline =
-			hpsa_volume_offline(h, scsi3addr);
+			(u8) hpsa_volume_offline(h, scsi3addr);
 	} else {
 		this_device->raid_level = RAID_UNKNOWN;
 		this_device->offload_config = 0;