[PATCH 4/4] scsi: pm8001: fix pm8001_store_update_fw

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The current implementation may mix the negative value returned
from pm8001_set_nvmd with with count. -(-ENOMEM) could be interpreted
as bytes programmed, this patch fixes it.

Signed-off-by: Tomas Henzl <thenzl@xxxxxxxxxx>
---
 drivers/scsi/pm8001/pm8001_ctl.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c
index 8f1f882..847755b 100644
--- a/drivers/scsi/pm8001/pm8001_ctl.c
+++ b/drivers/scsi/pm8001/pm8001_ctl.c
@@ -650,14 +650,14 @@ static ssize_t pm8001_store_update_fw(struct device *cdev,
 	cmd_ptr = kzalloc(count*2, GFP_KERNEL);
 
 	if (!cmd_ptr) {
-		err = FAIL_OUT_MEMORY;
+		err = -FAIL_OUT_MEMORY;
 		goto out;
 	}
 
 	filename_ptr = cmd_ptr + count;
 	res = sscanf(buf, "%s %s", cmd_ptr, filename_ptr);
 	if (res != 2) {
-		err = FAIL_PARAMETERS;
+		err = -FAIL_PARAMETERS;
 		goto out1;
 	}
 
@@ -669,12 +669,12 @@ static ssize_t pm8001_store_update_fw(struct device *cdev,
 		}
 	}
 	if (flash_command == FLASH_CMD_NONE) {
-		err = FAIL_PARAMETERS;
+		err = -FAIL_PARAMETERS;
 		goto out1;
 	}
 
 	if (pm8001_ha->fw_status == FLASH_IN_PROGRESS) {
-		err = FLASH_IN_PROGRESS;
+		err = -FLASH_IN_PROGRESS;
 		goto out1;
 	}
 	err = request_firmware(&pm8001_ha->fw_image,
@@ -685,7 +685,7 @@ static ssize_t pm8001_store_update_fw(struct device *cdev,
 		PM8001_FAIL_DBG(pm8001_ha,
 			pm8001_printk("Failed to load firmware image file %s,"
 			" error %d\n", filename_ptr, err));
-		err = FAIL_OPEN_BIOS_FILE;
+		err = -FAIL_OPEN_BIOS_FILE;
 		goto out1;
 	}
 
@@ -700,7 +700,7 @@ static ssize_t pm8001_store_update_fw(struct device *cdev,
 		break;
 	default:
 		pm8001_ha->fw_status = FAIL_PARAMETERS;
-		err = FAIL_PARAMETERS;
+		err = -FAIL_PARAMETERS;
 		break;
 	}
 	release_firmware(pm8001_ha->fw_image);
@@ -709,10 +709,10 @@ out1:
 out:
 	pm8001_ha->fw_status = err;
 
-	if (!err)
-		return count;
-	else
-		return -err;
+	if (err)
+		return err;
+
+	return count;
 }
 
 static ssize_t pm8001_show_update_fw(struct device *cdev,
-- 
1.8.3.1

--
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




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux