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

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.