2021-09-09 09:52:08

by Jiapeng Chong

[permalink] [raw]
Subject: [PATCH] nvme: Fix missing error code in nvme_configure_directives()

From: chongjiapeng <[email protected]>

The error code is missing in this code scenario, add the error code
'-EINVAL' to the return value 'ret'.

Eliminate the follow smatch warning:

drivers/nvme/host/core.c:786 nvme_configure_directives() warn: missing
error code 'ret'.

Reported-by: Abaci Robot <[email protected]>
Fixes: f5d118406247 ("nvme: add support for streams and directives")
Signed-off-by: chongjiapeng <[email protected]>
---
drivers/nvme/host/core.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 7efb31b..84abf1f 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -783,6 +783,7 @@ static int nvme_configure_directives(struct nvme_ctrl *ctrl)
if (ctrl->nssa < BLK_MAX_WRITE_HINTS - 1) {
dev_info(ctrl->device, "too few streams (%u) available\n",
ctrl->nssa);
+ ret = -EINVAL;
goto out_disable_stream;
}

--
1.8.3.1


2021-09-09 14:49:23

by Keith Busch

[permalink] [raw]
Subject: Re: [PATCH] nvme: Fix missing error code in nvme_configure_directives()

On Thu, Sep 09, 2021 at 05:50:21PM +0800, Jiapeng Chong wrote:
> From: chongjiapeng <[email protected]>
>
> The error code is missing in this code scenario, add the error code
> '-EINVAL' to the return value 'ret'.
>
> Eliminate the follow smatch warning:
>
> drivers/nvme/host/core.c:786 nvme_configure_directives() warn: missing
> error code 'ret'.

Nak, the code is correct as-is. Returning a negative error for this
harmless condition will result in disabling the controller when we can
proceed just fine without directives.

2021-09-09 14:51:26

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH] nvme: Fix missing error code in nvme_configure_directives()

On Thu, Sep 09, 2021 at 07:47:39AM -0700, Keith Busch wrote:
> On Thu, Sep 09, 2021 at 05:50:21PM +0800, Jiapeng Chong wrote:
> > From: chongjiapeng <[email protected]>
> >
> > The error code is missing in this code scenario, add the error code
> > '-EINVAL' to the return value 'ret'.
> >
> > Eliminate the follow smatch warning:
> >
> > drivers/nvme/host/core.c:786 nvme_configure_directives() warn: missing
> > error code 'ret'.
>
> Nak, the code is correct as-is. Returning a negative error for this
> harmless condition will result in disabling the controller when we can
> proceed just fine without directives.

Oh, indeed. We should probably throw a comment in to make this more
clear.

2022-02-15 05:26:30

by Keith Busch

[permalink] [raw]
Subject: Re: [PATCH] nvme: Fix missing error code in nvme_configure_directives()

On Tue, Feb 15, 2022 at 11:36:32AM +0800, Jiapeng Chong wrote:
> The error code is missing in this code scenario, add the error code
> '-EINVAL' to the return value 'ret'.
>
> Eliminate the follow smatch warning:
>
> drivers/nvme/host/core.c:780 nvme_configure_directives() warn: missing
> error code 'ret'.

Nak, the code is correct as-is, just like it was the previous time you
posted this patch:

http://lists.infradead.org/pipermail/linux-nvme/2021-September/027339.html

2022-02-15 06:48:11

by Christophe JAILLET

[permalink] [raw]
Subject: Re: [PATCH] nvme: Fix missing error code in nvme_configure_directives()

Le 15/02/2022 à 04:55, Keith Busch a écrit :
> On Tue, Feb 15, 2022 at 11:36:32AM +0800, Jiapeng Chong wrote:
>> The error code is missing in this code scenario, add the error code
>> '-EINVAL' to the return value 'ret'.
>>
>> Eliminate the follow smatch warning:
>>
>> drivers/nvme/host/core.c:780 nvme_configure_directives() warn: missing
>> error code 'ret'.
>
> Nak, the code is correct as-is, just like it was the previous time you
> posted this patch:
>
> http://lists.infradead.org/pipermail/linux-nvme/2021-September/027339.html
>

Hi,

maybe an explicit 'ret = 0;' (and eventually a comment saying why) would
help here?

The code really looks like an error handling path (and will keep getting
some patches for it because of bots).

Just my 2c.

CJ