scsi: pm8001: fix pm8001_store_update_fw
Subsystems (2)
PATCH 4/4 scsi: pm8001: fix pm8001_store_update_fw
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.
--- drivers/scsi/pm8001/pm8001_ctl.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/scsi/pm8001/pm8001_ctl.c +10 -10
@@ -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,
Signature · 1 line
1.8.3.1
Quoted 3 lines · Tomas Henzl
The current implementation may mix the negative value returned from
pm8001_set_nvmdwith with count. -(-ENOMEM) could be interpreted as bytes programmed, this patch fixes it.
This still doesn;t look correct to me as err mixes up the driver internal FAIL_* codes with Linux error codes. It seems like for the FAIL_* codes should only go into ->fw_status and the return value should be a proper Linux error code.
Funny fact: the FAIL_* / FLASH_IN_PROGRESS codes seems to be the same between aic94xx and pm8001.
Quoted 8 lines · Christoph Hellwig
Quoted 3 lines · Tomas Henzl
The current implementation may mix the negative value returned from
pm8001_set_nvmdwith with count. -(-ENOMEM) could be interpreted as bytes programmed, this patch fixes it.This still doesn;t look correct to me as err mixes up the driver internal FAIL_* codes with Linux error codes. It seems like for the FAIL_* codes should only go into ->fw_status and the return value should be a proper Linux error code.
And the fw_status might be later used to show error strings in pm8001_show_update_fw, if it is so it depends on the flash utility but it seems likely.
Quoted 3 lines
Funny fact: the FAIL_* /
FLASH_IN_PROGRESScodes seems to be the same between aic94xx and pm8001.
And similar story there too - asd_store_update_bios -...- asd_poll_flash(might return -ENOENT)
Maybe the flash utility ignores the return value or it has never happened.
---------------------
I'll try to find what seems to be the most probable way and post it in few days. This patch is not related to the patches 1-3/4, so just wait with this one.
Thanks, Tomas
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 12 lines · Tomas Henzl
Quoted 8 lines · Christoph Hellwig
Quoted 3 lines · Tomas Henzl
The current implementation may mix the negative value returned from
pm8001_set_nvmdwith with count. -(-ENOMEM) could be interpreted as bytes programmed, this patch fixes it.This still doesn;t look correct to me as err mixes up the driver internal FAIL_* codes with Linux error codes. It seems like for the FAIL_* codes should only go into ->fw_status and the return value should be a proper Linux error code.
And the
fw_statusmight be later used to show error strings inpm8001_show_update_fw, if it is so it depends on the flash utility but it seems likely.
Quoted 8 lines
Quoted 2 lines
Funny fact: the FAIL_* /
FLASH_IN_PROGRESScodes seems to be the same between aic94xx and pm8001.And similar story there too -
asd_store_update_bios-...-asd_poll_flash(might return -ENOENT)Maybe the flash utility ignores the return value or it has never happened.
---------------------I'll try to find what seems to be the most probable way and post it in few days.
Christoph,
from few days it is three weeks and the patch has been just replaced by "[PATCH 1/3] pm8001: fix pm8001_store_update_fw" sent by Suresh, so you can drop this patch.
(I've asked Suresh off-list to test it, I didn't want to brick my card by testing fw flashes.)
Thanks,
Tomas
Quoted 12 lines
This patch is not related to the patches 1-3/4, so just wait with this one.
Thanks, Tomas
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html