mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] NTB/msi: fix NULL deref when msi_first_desc() returns NULL
@ 2026-11-20  8:37 zhangjiao2
  2026-11-25  5:00 ` Koichiro Den
  0 siblings, 1 reply; 2+ messages in thread
From: zhangjiao2 @ 2026-11-20  8:37 UTC (permalink / raw)
  To: linux; +Cc: jdmason, linux-kernel, trivial, zhang jiao

From: zhang jiao <zhangjiao2@cmss.chinamobile.com>

msi_first_desc() can return NULL if no MSI descriptors are found,
but ntb_msi_setup_mws() dereferences desc->msg unconditionally
inside the scoped_guard block. Add a NULL check and return -ENODEV
to prevent a null pointer dereference.

Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
---
 drivers/ntb/msi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/ntb/msi.c b/drivers/ntb/msi.c
index 13e9f52ec8cc..cfe2125b2fe0 100644
--- a/drivers/ntb/msi.c
+++ b/drivers/ntb/msi.c
@@ -108,6 +108,8 @@ int ntb_msi_setup_mws(struct ntb_dev *ntb)
 
 	scoped_guard (msi_descs_lock, &ntb->pdev->dev) {
 		desc = msi_first_desc(&ntb->pdev->dev, MSI_DESC_ASSOCIATED);
+		if (!desc)
+			return -ENODEV;
 		addr = desc->msg.address_lo + ((uint64_t)desc->msg.address_hi << 32);
 	}
 
-- 
2.33.0




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

end of thread, other threads:[~2026-11-25  5:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20  8:37 [PATCH] NTB/msi: fix NULL deref when msi_first_desc() returns NULL zhangjiao2
2026-11-25  5:00 ` Koichiro Den

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®