Re: [PATCH] slimbus: qcom-ngd: fix NULL pointer dereference in qcom_slim_ngd_xfer_msg()

From: Dmitry Baryshkov

Date: Mon Mar 23 2026 - 20:31:03 EST


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@xxxxxxxxx>
> ---
> 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