linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nvme: Fix missing error code in nvme_configure_directives()
@ 2021-09-09  9:50 Jiapeng Chong
  2021-09-09 14:07 ` Christoph Hellwig
  2021-09-09 14:47 ` Keith Busch
  0 siblings, 2 replies; 7+ messages in thread
From: Jiapeng Chong @ 2021-09-09  9:50 UTC (permalink / raw)
  To: kbusch; +Cc: axboe, hch, sagi, linux-nvme, linux-kernel, chongjiapeng

From: chongjiapeng <jiapeng.chong@linux.alibaba.com>

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 <abaci@linux.alibaba.com>
Fixes: f5d118406247 ("nvme: add support for streams and directives")
Signed-off-by: chongjiapeng <jiapeng.chong@linux.alibaba.com>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] nvme: Fix missing error code in nvme_configure_directives()
  2021-09-09  9:50 [PATCH] nvme: Fix missing error code in nvme_configure_directives() Jiapeng Chong
@ 2021-09-09 14:07 ` Christoph Hellwig
  2021-09-09 14:47 ` Keith Busch
  1 sibling, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2021-09-09 14:07 UTC (permalink / raw)
  To: Jiapeng Chong; +Cc: kbusch, axboe, hch, sagi, linux-nvme, linux-kernel

Thanks,

applied to nvme-5.15.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] nvme: Fix missing error code in nvme_configure_directives()
  2021-09-09  9:50 [PATCH] nvme: Fix missing error code in nvme_configure_directives() Jiapeng Chong
  2021-09-09 14:07 ` Christoph Hellwig
@ 2021-09-09 14:47 ` Keith Busch
  2021-09-09 14:50   ` Christoph Hellwig
  1 sibling, 1 reply; 7+ messages in thread
From: Keith Busch @ 2021-09-09 14:47 UTC (permalink / raw)
  To: Jiapeng Chong; +Cc: axboe, hch, sagi, linux-nvme, linux-kernel

On Thu, Sep 09, 2021 at 05:50:21PM +0800, Jiapeng Chong wrote:
> From: chongjiapeng <jiapeng.chong@linux.alibaba.com>
> 
> 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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] nvme: Fix missing error code in nvme_configure_directives()
  2021-09-09 14:47 ` Keith Busch
@ 2021-09-09 14:50   ` Christoph Hellwig
  0 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2021-09-09 14:50 UTC (permalink / raw)
  To: Keith Busch; +Cc: Jiapeng Chong, axboe, hch, sagi, linux-nvme, linux-kernel

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 <jiapeng.chong@linux.alibaba.com>
> > 
> > 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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] nvme: Fix missing error code in nvme_configure_directives()
  2022-02-15  3:55 ` Keith Busch
@ 2022-02-15  6:22   ` Christophe JAILLET
  0 siblings, 0 replies; 7+ messages in thread
From: Christophe JAILLET @ 2022-02-15  6:22 UTC (permalink / raw)
  To: Keith Busch, Jiapeng Chong
  Cc: axboe, hch, sagi, linux-nvme, linux-kernel, Abaci Robot

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] nvme: Fix missing error code in nvme_configure_directives()
  2022-02-15  3:36 Jiapeng Chong
@ 2022-02-15  3:55 ` Keith Busch
  2022-02-15  6:22   ` Christophe JAILLET
  0 siblings, 1 reply; 7+ messages in thread
From: Keith Busch @ 2022-02-15  3:55 UTC (permalink / raw)
  To: Jiapeng Chong; +Cc: axboe, hch, sagi, linux-nvme, linux-kernel, Abaci Robot

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] nvme: Fix missing error code in nvme_configure_directives()
@ 2022-02-15  3:36 Jiapeng Chong
  2022-02-15  3:55 ` Keith Busch
  0 siblings, 1 reply; 7+ messages in thread
From: Jiapeng Chong @ 2022-02-15  3:36 UTC (permalink / raw)
  To: kbusch
  Cc: axboe, hch, sagi, linux-nvme, linux-kernel, Jiapeng Chong, Abaci Robot

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'.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 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 79005ea1a33e..53b37f333170 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -777,6 +777,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;
 	}
 
-- 
2.20.1.7.g153144c


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-02-15  6:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-09  9:50 [PATCH] nvme: Fix missing error code in nvme_configure_directives() Jiapeng Chong
2021-09-09 14:07 ` Christoph Hellwig
2021-09-09 14:47 ` Keith Busch
2021-09-09 14:50   ` Christoph Hellwig
2022-02-15  3:36 Jiapeng Chong
2022-02-15  3:55 ` Keith Busch
2022-02-15  6:22   ` Christophe JAILLET

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).