2021-10-18 03:50:18

by Zheyu Ma

[permalink] [raw]
Subject: [PATCH] scsi: qla2xxx: Return -ENOMEM if kzalloc() fails

During the process of driver probing, probe function should return < 0
for failure, otherwise kernel will treat value > 0 as success.

Signed-off-by: Zheyu Ma <[email protected]>
---
drivers/scsi/qla2xxx/qla_os.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index d2e40aaba734..836fedcea241 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -4157,7 +4157,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
ql_dbg_pci(ql_dbg_init, ha->pdev,
0xe0ee, "%s: failed alloc dsd\n",
__func__);
- return 1;
+ return -ENOMEM;
}
ha->dif_bundle_kallocs++;

--
2.17.6


2021-10-18 14:23:57

by Himanshu Madhani

[permalink] [raw]
Subject: Re: [PATCH] scsi: qla2xxx: Return -ENOMEM if kzalloc() fails



> On Oct 17, 2021, at 8:56 PM, Zheyu Ma <[email protected]> wrote:
>
> During the process of driver probing, probe function should return < 0
> for failure, otherwise kernel will treat value > 0 as success.
>
> Signed-off-by: Zheyu Ma <[email protected]>
> ---
> drivers/scsi/qla2xxx/qla_os.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
> index d2e40aaba734..836fedcea241 100644
> --- a/drivers/scsi/qla2xxx/qla_os.c
> +++ b/drivers/scsi/qla2xxx/qla_os.c
> @@ -4157,7 +4157,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
> ql_dbg_pci(ql_dbg_init, ha->pdev,
> 0xe0ee, "%s: failed alloc dsd\n",
> __func__);
> - return 1;
> + return -ENOMEM;
> }
> ha->dif_bundle_kallocs++;
>
> --
> 2.17.6
>

Reviewed-by: Himanshu Madhani <[email protected]>

--
Himanshu Madhani Oracle Linux Engineering

2021-10-19 03:48:46

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH] scsi: qla2xxx: Return -ENOMEM if kzalloc() fails

On Mon, 18 Oct 2021 01:56:21 +0000, Zheyu Ma wrote:

> During the process of driver probing, probe function should return < 0
> for failure, otherwise kernel will treat value > 0 as success.
>
>

Applied to 5.15/scsi-fixes, thanks!

[1/1] scsi: qla2xxx: Return -ENOMEM if kzalloc() fails
https://git.kernel.org/mkp/scsi/c/06634d5b6e92

--
Martin K. Petersen Oracle Linux Engineering