[PATCH 01/10] mailbox: qcom-ipcc: Skip of_node_put() on phandle parse failure
From: Lee Jones
Date: Thu Dec 03 2026 - 03:28:30 EST
qcom_ipcc_setup_mbox() declares curr_ph on the stack without
initialising it and unconditionally calls of_node_put(curr_ph.np)
immediately after of_parse_phandle_with_args(), before checking whether
the call succeeded. If of_parse_phandle_with_args() fails on the first
iteration, of_node_put() dereferences an uninitialised stack pointer;
on subsequent iterations it drops the reference to the previous node a
second time.
Skip the remainder of the loop iteration when
of_parse_phandle_with_args() returns an error, and only release
curr_ph.np on success.
Fixes: e9d50e4b4d04 ("mailbox: qcom-ipcc: Dynamic alloc for channel arrangement")
Closes: https://sashiko.dev/#/bug/linux-2052db5b-c6e1-4da3-aab4-7612dc67c78b
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
Cc: Huang Yiwei <quic_hyiwei@xxxxxxxxxxx>
Cc: Jassi Brar <jassisinghbrar@xxxxxxxxx>
Cc: Kumar Gutta <vnkgutta@xxxxxxxxxxxxxx>
Cc: linux-arm-msm@xxxxxxxxxxxxxxx
Cc: Manivannan Sadhasivam <mani@xxxxxxxxxx>
drivers/mailbox/qcom-ipcc.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/mailbox/qcom-ipcc.c b/drivers/mailbox/qcom-ipcc.c
index bb54295e03ce..19fea341bd12 100644
--- a/drivers/mailbox/qcom-ipcc.c
+++ b/drivers/mailbox/qcom-ipcc.c
@@ -239,9 +239,12 @@ static int qcom_ipcc_setup_mbox(struct qcom_ipcc *ipcc,
for (j = 0; j < i; j++) {
ret = of_parse_phandle_with_args(client_dn, "mboxes",
"#mbox-cells", j, &curr_ph);
- of_node_put(curr_ph.np);
- if (!ret && curr_ph.np == controller_dn)
+ if (ret)
+ continue;
+
+ if (curr_ph.np == controller_dn)
ipcc->num_chans++;
+ of_node_put(curr_ph.np);
}
}
--
2.56.1.911.g883d8bcb20-goog