From: Prathamesh Deshpande <prathameshdeshpande7@gmail.com>
To: Leon Romanovsky <leon@kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>
Cc: Haggai Eran <haggaie@mellanox.com>,
Doug Ledford <dledford@redhat.com>,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
Prathamesh Deshpande <prathameshdeshpande7@gmail.com>
Subject: [PATCH] IB/mlx5: Fix potential NULL dereference in query_device
Date: Tue, 31 Mar 2026 02:44:27 +0100 [thread overview]
Message-ID: <20260331014427.11756-1-prathameshdeshpande7@gmail.com> (raw)
Smatch reported an inconsistent NULL check for 'uhw' in
mlx5_ib_query_device(). While 'uhw_outlen' is checked at the end of
the function before calling ib_copy_to_udata(), 'uhw' is explicitly
checked for NULL earlier in the same function.
If a caller provides a non-zero 'uhw_outlen' but a NULL 'uhw' pointer,
ib_copy_to_udata() will attempt to dereference 'uhw', leading to a
kernel panic. Fix this by checking the 'uhw' pointer directly.
Fixes: 4835709176e8 ("RDMA/mlx5: Don't fake udata for kernel path")
Signed-off-by: Prathamesh Deshpande <prathameshdeshpande7@gmail.com>
---
drivers/infiniband/hw/mlx5/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 635002e684a5..471dc8df4a52 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -1353,7 +1353,7 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
fill_esw_mgr_reg_c0(mdev, &resp);
}
- if (uhw_outlen) {
+ if (uhw) {
err = ib_copy_to_udata(uhw, &resp, resp.response_length);
if (err)
--
2.43.0
next reply other threads:[~2026-03-31 1:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 1:44 Prathamesh Deshpande [this message]
2026-03-31 13:49 ` [PATCH] IB/mlx5: Fix potential NULL dereference in query_device Leon Romanovsky
2026-03-31 18:25 ` Prathamesh Deshpande
2026-03-31 19:04 ` Leon Romanovsky
[not found] <202603311604.GD814676@unreal>
2026-03-31 21:57 ` Prathamesh Deshpande
2026-04-09 9:51 ` Leon Romanovsky
2026-04-10 1:07 ` Prathamesh Deshpande
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260331014427.11756-1-prathameshdeshpande7@gmail.com \
--to=prathameshdeshpande7@gmail.com \
--cc=dledford@redhat.com \
--cc=haggaie@mellanox.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox