* [PATCH] slimbus: qcom-ngd: fix NULL pointer dereference in qcom_slim_ngd_xfer_msg()
@ 2026-03-22 12:46 Anas Iqbal
2026-03-24 0:24 ` Dmitry Baryshkov
0 siblings, 1 reply; 2+ messages in thread
From: Anas Iqbal @ 2026-03-22 12:46 UTC (permalink / raw)
To: srini; +Cc: gregkh, vkoul, linux-arm-msm, linux-sound, linux-kernel,
Anas Iqbal
txn->msg is dereferenced without a prior NULL check in
qcom_slim_ngd_xfer_msg(), which may lead to a NULL pointer
dereference.
Although current callers initialize txn->msg, add a defensive
check to prevent potential crashes if a NULL pointer is passed.
Fixes: 917809e2280bb ("slimbus: ngd: Add qcom SLIMBus NGD driver")
Signed-off-by: Anas Iqbal <mohd.abd.6602@gmail.com>
---
drivers/slimbus/qcom-ngd-ctrl.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
index 9aa7218b4e8d..241f5e08b582 100644
--- a/drivers/slimbus/qcom-ngd-ctrl.c
+++ b/drivers/slimbus/qcom-ngd-ctrl.c
@@ -805,6 +805,9 @@ static int qcom_slim_ngd_xfer_msg(struct slim_controller *sctrl,
if (txn->dt == SLIM_MSG_DEST_ENUMADDR)
return -EPROTONOSUPPORT;
+ if (!txn->msg)
+ return -EINVAL;
+
if (txn->msg->num_bytes > SLIM_MSGQ_BUF_LEN ||
txn->rl > SLIM_MSGQ_BUF_LEN) {
dev_err(ctrl->dev, "msg exceeds HW limit\n");
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] slimbus: qcom-ngd: fix NULL pointer dereference in qcom_slim_ngd_xfer_msg()
2026-03-22 12:46 [PATCH] slimbus: qcom-ngd: fix NULL pointer dereference in qcom_slim_ngd_xfer_msg() Anas Iqbal
@ 2026-03-24 0:24 ` Dmitry Baryshkov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Baryshkov @ 2026-03-24 0:24 UTC (permalink / raw)
To: Anas Iqbal; +Cc: srini, gregkh, vkoul, linux-arm-msm, linux-sound, linux-kernel
On Sun, Mar 22, 2026 at 12:46:47PM +0000, Anas Iqbal wrote:
> txn->msg is dereferenced without a prior NULL check in
> qcom_slim_ngd_xfer_msg(), which may lead to a NULL pointer
> dereference.
>
> Although current callers initialize txn->msg, add a defensive
> check to prevent potential crashes if a NULL pointer is passed.
Defensive coding is generally not appreciated in the kernel.
>
> Fixes: 917809e2280bb ("slimbus: ngd: Add qcom SLIMBus NGD driver")
> Signed-off-by: Anas Iqbal <mohd.abd.6602@gmail.com>
> ---
> drivers/slimbus/qcom-ngd-ctrl.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
> index 9aa7218b4e8d..241f5e08b582 100644
> --- a/drivers/slimbus/qcom-ngd-ctrl.c
> +++ b/drivers/slimbus/qcom-ngd-ctrl.c
> @@ -805,6 +805,9 @@ static int qcom_slim_ngd_xfer_msg(struct slim_controller *sctrl,
> if (txn->dt == SLIM_MSG_DEST_ENUMADDR)
> return -EPROTONOSUPPORT;
>
> + if (!txn->msg)
> + return -EINVAL;
> +
> if (txn->msg->num_bytes > SLIM_MSGQ_BUF_LEN ||
> txn->rl > SLIM_MSGQ_BUF_LEN) {
> dev_err(ctrl->dev, "msg exceeds HW limit\n");
> --
> 2.43.0
>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-24 0:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-22 12:46 [PATCH] slimbus: qcom-ngd: fix NULL pointer dereference in qcom_slim_ngd_xfer_msg() Anas Iqbal
2026-03-24 0:24 ` Dmitry Baryshkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox