* [patch] [SCSI] qla2xxx: fix error handling of qla2x00_mem_alloc()
@ 2014-01-21 7:00 Dan Carpenter
2014-01-22 2:00 ` Saurav Kashyap
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2014-01-21 7:00 UTC (permalink / raw)
To: qla2xxx-upstream, Anirban Chakraborty
Cc: James E.J. Bottomley, linux-scsi, kernel-janitors
qla2x00_mem_alloc() returns 1 on success and -ENOMEM on failure. On the
one hand the caller assumes non-zero is success but on the other hand
the caller also assumes that it returns an error code.
I've fixed it to return zero on success and a negative error code on
failure. This matches the documentation as well.
Fixes: e315cd28b9ef ('[SCSI] qla2xxx: Code changes for qla data structure refactoring')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 89a53002b585..8d5a67fcffa1 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -2536,7 +2536,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
ha->flags.enable_64bit_addressing ? "enable" :
"disable");
ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp);
- if (!ret) {
+ if (ret) {
ql_log_pci(ql_log_fatal, pdev, 0x0031,
"Failed to allocate memory for adapter, aborting.\n");
@@ -3481,7 +3481,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
"loop_id_map=%p. \n", ha->loop_id_map);
}
- return 1;
+ return 0;
fail_async_pd:
dma_pool_free(ha->s_dma_pool, ha->ex_init_cb, ha->ex_init_cb_dma);
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [patch] [SCSI] qla2xxx: fix error handling of qla2x00_mem_alloc()
2014-01-21 7:00 [patch] [SCSI] qla2xxx: fix error handling of qla2x00_mem_alloc() Dan Carpenter
@ 2014-01-22 2:00 ` Saurav Kashyap
0 siblings, 0 replies; 2+ messages in thread
From: Saurav Kashyap @ 2014-01-22 2:00 UTC (permalink / raw)
To: Dan Carpenter, Dept-Eng QLA2xxx Upstream, Anirban Chakraborty
Cc: James E.J. Bottomley, linux-scsi, kernel-janitors@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 1428 bytes --]
Acked-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Thanks,
~Saurav
>qla2x00_mem_alloc() returns 1 on success and -ENOMEM on failure. On the
>one hand the caller assumes non-zero is success but on the other hand
>the caller also assumes that it returns an error code.
>
>I've fixed it to return zero on success and a negative error code on
>failure. This matches the documentation as well.
>
>Fixes: e315cd28b9ef ('[SCSI] qla2xxx: Code changes for qla data structure
>refactoring')
>Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
>diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
>index 89a53002b585..8d5a67fcffa1 100644
>--- a/drivers/scsi/qla2xxx/qla_os.c
>+++ b/drivers/scsi/qla2xxx/qla_os.c
>@@ -2536,7 +2536,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const
>struct pci_device_id *id)
> ha->flags.enable_64bit_addressing ? "enable" :
> "disable");
> ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp);
>- if (!ret) {
>+ if (ret) {
> ql_log_pci(ql_log_fatal, pdev, 0x0031,
> "Failed to allocate memory for adapter, aborting.\n");
>
>@@ -3481,7 +3481,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t
>req_len, uint16_t rsp_len,
> "loop_id_map=%p. \n", ha->loop_id_map);
> }
>
>- return 1;
>+ return 0;
>
> fail_async_pd:
> dma_pool_free(ha->s_dma_pool, ha->ex_init_cb, ha->ex_init_cb_dma);
[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 4586 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-22 2:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-21 7:00 [patch] [SCSI] qla2xxx: fix error handling of qla2x00_mem_alloc() Dan Carpenter
2014-01-22 2:00 ` Saurav Kashyap
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox