All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme: fix bogus kzalloc() return check in nvme_init_effects_log()
@ 2025-01-13 17:30 Jens Axboe
  2025-01-13 17:39 ` Keith Busch
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Jens Axboe @ 2025-01-13 17:30 UTC (permalink / raw)
  To: linux-nvme@lists.infradead.org
  Cc: Keith Busch, Christoph Hellwig, Sagi Grimberg, keisuke.nishimura

nvme_init_effects_log() returns failure when kzalloc() is successful,
which is obviously wrong and causes failures to boot. Correct the
check.

Fixes: d4a95adeabc6 ("nvme: Add error path for xa_store in nvme_init_effects")
Signed-off-by: Jens Axboe <axboe@kernel.dk>

---

Caused a boot failure on the first test system I tried. Not sure how
this got this far without being seen...

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 9e7f1bb81973..0d21258e2283 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3182,7 +3182,7 @@ static int nvme_init_effects_log(struct nvme_ctrl *ctrl,
 	struct nvme_effects_log *effects, *old;
 
 	effects = kzalloc(sizeof(*effects), GFP_KERNEL);
-	if (effects)
+	if (!effects)
 		return -ENOMEM;
 
 	old = xa_store(&ctrl->cels, csi, effects, GFP_KERNEL);

-- 
Jens Axboe



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

* Re: [PATCH] nvme: fix bogus kzalloc() return check in nvme_init_effects_log()
  2025-01-13 17:30 [PATCH] nvme: fix bogus kzalloc() return check in nvme_init_effects_log() Jens Axboe
@ 2025-01-13 17:39 ` Keith Busch
  2025-01-13 18:00   ` Jens Axboe
  2025-01-13 17:46 ` Keisuke Nishimura
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Keith Busch @ 2025-01-13 17:39 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-nvme@lists.infradead.org, Christoph Hellwig, Sagi Grimberg,
	keisuke.nishimura

On Mon, Jan 13, 2025 at 10:30:06AM -0700, Jens Axboe wrote:
> nvme_init_effects_log() returns failure when kzalloc() is successful,
> which is obviously wrong and causes failures to boot. Correct the
> check.
> 
> Fixes: d4a95adeabc6 ("nvme: Add error path for xa_store in nvme_init_effects")
> Signed-off-by: Jens Axboe <axboe@kernel.dk>

Oops. Thanks for the fix

Reviewed-by: Keith Busch <kbusch@kernel.org>

Also applied to nvme-6.14, but feel free to take it directly to
block/for-6.14.

> Caused a boot failure on the first test system I tried. Not sure how
> this got this far without being seen...

I think we've a gap in our blktests for checking driver backward
compatibility. The devices we test against support the Effects log, so
we didn't see this fallback path for older spec revision devices tested
out.


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

* Re: [PATCH] nvme: fix bogus kzalloc() return check in nvme_init_effects_log()
  2025-01-13 17:30 [PATCH] nvme: fix bogus kzalloc() return check in nvme_init_effects_log() Jens Axboe
  2025-01-13 17:39 ` Keith Busch
@ 2025-01-13 17:46 ` Keisuke Nishimura
  2025-01-13 20:01 ` Chaitanya Kulkarni
  2025-01-13 20:03 ` Sagi Grimberg
  3 siblings, 0 replies; 6+ messages in thread
From: Keisuke Nishimura @ 2025-01-13 17:46 UTC (permalink / raw)
  To: Jens Axboe, linux-nvme@lists.infradead.org
  Cc: Keith Busch, Christoph Hellwig, Sagi Grimberg



On 13/01/2025 18:30, Jens Axboe wrote:
> nvme_init_effects_log() returns failure when kzalloc() is successful,
> which is obviously wrong and causes failures to boot. Correct the
> check.

Sorry, I should have checked more carefully here... Thank you for this fix.

Keisuke

> 
> Fixes: d4a95adeabc6 ("nvme: Add error path for xa_store in nvme_init_effects")
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> 
> ---
> 
> Caused a boot failure on the first test system I tried. Not sure how
> this got this far without being seen...
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 9e7f1bb81973..0d21258e2283 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -3182,7 +3182,7 @@ static int nvme_init_effects_log(struct nvme_ctrl *ctrl,
>   	struct nvme_effects_log *effects, *old;
>   
>   	effects = kzalloc(sizeof(*effects), GFP_KERNEL);
> -	if (effects)
> +	if (!effects)
>   		return -ENOMEM;
>   
>   	old = xa_store(&ctrl->cels, csi, effects, GFP_KERNEL);
> 


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

* Re: [PATCH] nvme: fix bogus kzalloc() return check in nvme_init_effects_log()
  2025-01-13 17:39 ` Keith Busch
@ 2025-01-13 18:00   ` Jens Axboe
  0 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2025-01-13 18:00 UTC (permalink / raw)
  To: Keith Busch
  Cc: linux-nvme@lists.infradead.org, Christoph Hellwig, Sagi Grimberg,
	keisuke.nishimura

On 1/13/25 10:39 AM, Keith Busch wrote:
> On Mon, Jan 13, 2025 at 10:30:06AM -0700, Jens Axboe wrote:
>> nvme_init_effects_log() returns failure when kzalloc() is successful,
>> which is obviously wrong and causes failures to boot. Correct the
>> check.
>>
>> Fixes: d4a95adeabc6 ("nvme: Add error path for xa_store in nvme_init_effects")
>> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> 
> Oops. Thanks for the fix
> 
> Reviewed-by: Keith Busch <kbusch@kernel.org>
> 
> Also applied to nvme-6.14, but feel free to take it directly to
> block/for-6.14.

I did, figured that was easier. And if it fails on the one test system
I tested on, guessing it'd break someone using linux-next as well. Hence
let's just shove it in and move on.

-- 
Jens Axboe



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

* Re: [PATCH] nvme: fix bogus kzalloc() return check in nvme_init_effects_log()
  2025-01-13 17:30 [PATCH] nvme: fix bogus kzalloc() return check in nvme_init_effects_log() Jens Axboe
  2025-01-13 17:39 ` Keith Busch
  2025-01-13 17:46 ` Keisuke Nishimura
@ 2025-01-13 20:01 ` Chaitanya Kulkarni
  2025-01-13 20:03 ` Sagi Grimberg
  3 siblings, 0 replies; 6+ messages in thread
From: Chaitanya Kulkarni @ 2025-01-13 20:01 UTC (permalink / raw)
  To: Jens Axboe, linux-nvme@lists.infradead.org
  Cc: Keith Busch, Christoph Hellwig, Sagi Grimberg,
	keisuke.nishimura@inria.fr

On 1/13/25 09:30, Jens Axboe wrote:
> nvme_init_effects_log() returns failure when kzalloc() is successful,
> which is obviously wrong and causes failures to boot. Correct the
> check.
>
> Fixes: d4a95adeabc6 ("nvme: Add error path for xa_store in nvme_init_effects")
> Signed-off-by: Jens Axboe<axboe@kernel.dk>

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck



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

* Re: [PATCH] nvme: fix bogus kzalloc() return check in nvme_init_effects_log()
  2025-01-13 17:30 [PATCH] nvme: fix bogus kzalloc() return check in nvme_init_effects_log() Jens Axboe
                   ` (2 preceding siblings ...)
  2025-01-13 20:01 ` Chaitanya Kulkarni
@ 2025-01-13 20:03 ` Sagi Grimberg
  3 siblings, 0 replies; 6+ messages in thread
From: Sagi Grimberg @ 2025-01-13 20:03 UTC (permalink / raw)
  To: Jens Axboe, linux-nvme@lists.infradead.org
  Cc: Keith Busch, Christoph Hellwig, keisuke.nishimura

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>


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

end of thread, other threads:[~2025-01-13 20:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-13 17:30 [PATCH] nvme: fix bogus kzalloc() return check in nvme_init_effects_log() Jens Axboe
2025-01-13 17:39 ` Keith Busch
2025-01-13 18:00   ` Jens Axboe
2025-01-13 17:46 ` Keisuke Nishimura
2025-01-13 20:01 ` Chaitanya Kulkarni
2025-01-13 20:03 ` Sagi Grimberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.