2017-08-15 20:18:21

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH] scsi: cxlflash: Fix an error handling path in 'cxlflash_disk_attach()'

'rc' is known to be 0 at this point.
If 'create_context()' fails, returns -ENOMEM instead of 0 which means
success.

Signed-off-by: Christophe JAILLET <[email protected]>
---
drivers/scsi/cxlflash/superpipe.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c
index ad0f9968ccfb..08da593cb2f6 100644
--- a/drivers/scsi/cxlflash/superpipe.c
+++ b/drivers/scsi/cxlflash/superpipe.c
@@ -1390,6 +1390,7 @@ static int cxlflash_disk_attach(struct scsi_device *sdev,
if (unlikely(!ctxi)) {
dev_err(dev, "%s: Failed to create context ctxid=%d\n",
__func__, ctxid);
+ rc = -ENOMEM;
goto err;
}

--
2.11.0


2017-08-16 00:21:40

by Matthew R. Ochs

[permalink] [raw]
Subject: Re: [PATCH] scsi: cxlflash: Fix an error handling path in 'cxlflash_disk_attach()'

> On Aug 15, 2017, at 3:18 PM, Christophe JAILLET <[email protected]> wrote:
>
> 'rc' is known to be 0 at this point.
> If 'create_context()' fails, returns -ENOMEM instead of 0 which means
> success.
>
> Signed-off-by: Christophe JAILLET <[email protected]>

Yep, that's a bug.

Acked-by: Matthew R. Ochs <[email protected]>

2017-08-16 02:11:58

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH] scsi: cxlflash: Fix an error handling path in 'cxlflash_disk_attach()'


Christophe,

> 'rc' is known to be 0 at this point.
> If 'create_context()' fails, returns -ENOMEM instead of 0 which means
> success.

Applied to 4.14/scsi-queue. Thanks!

--
Martin K. Petersen Oracle Linux Engineering

2017-08-16 05:32:31

by Andrew Donnellan

[permalink] [raw]
Subject: Re: [PATCH] scsi: cxlflash: Fix an error handling path in 'cxlflash_disk_attach()'

On 16/08/17 06:18, Christophe JAILLET wrote:
> 'rc' is known to be 0 at this point.
> If 'create_context()' fails, returns -ENOMEM instead of 0 which means
> success.
>
> Signed-off-by: Christophe JAILLET <[email protected]>

ENOMEM seems right here.

Reviewed-by: Andrew Donnellan <[email protected]>

> ---
> drivers/scsi/cxlflash/superpipe.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c
> index ad0f9968ccfb..08da593cb2f6 100644
> --- a/drivers/scsi/cxlflash/superpipe.c
> +++ b/drivers/scsi/cxlflash/superpipe.c
> @@ -1390,6 +1390,7 @@ static int cxlflash_disk_attach(struct scsi_device *sdev,
> if (unlikely(!ctxi)) {
> dev_err(dev, "%s: Failed to create context ctxid=%d\n",
> __func__, ctxid);
> + rc = -ENOMEM;
> goto err;
> }
>
>

--
Andrew Donnellan OzLabs, ADL Canberra
[email protected] IBM Australia Limited