The qcom,aoss-qmp binding describes three cooling devices, cx, mx and ebi, but the driver allocates space for two. The registration loop stores one entry for each child that has #cooling-cells, so a device tree with all three children writes past the end of qmp->cooling_devs. Size the array for three entries, and stop the loop with a warning if a device tree has more children than the binding allows. No in-tree device tree has all three children today, so this is latent, but the binding permits it. Fixes: 05589b30b21a ("soc: qcom: Extend AOSS QMP driver to support resources that are used to wake up the SoC.") Cc: stable@vger.kernel.org Signed-off-by: Anup Vishwakarma --- drivers/soc/qcom/qcom_aoss.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/soc/qcom/qcom_aoss.c b/drivers/soc/qcom/qcom_aoss.c index 44b0c457e4ac..6bffbf4c64c2 100644 --- a/drivers/soc/qcom/qcom_aoss.c +++ b/drivers/soc/qcom/qcom_aoss.c @@ -47,7 +47,7 @@ /* 64 bytes is enough to store the requests and provides padding to 4 bytes */ #define QMP_MSG_LEN 64 -#define QMP_NUM_COOLING_RESOURCES 2 +#define QMP_NUM_COOLING_RESOURCES 3 /* cx, mx, ebi */ #define QMP_DEBUGFS_FILES 4 @@ -410,6 +410,11 @@ static int qmp_cooling_devices_register(struct qmp *qmp) for_each_available_child_of_node_scoped(np, child) { if (!of_property_present(child, "#cooling-cells")) continue; + if (count >= QMP_NUM_COOLING_RESOURCES) { + dev_warn(qmp->dev, "ignoring extra cooling device %pOFn\n", + child); + break; + } ret = qmp_cooling_device_add(qmp, &qmp->cooling_devs[count++], child); if (ret) -- 2.43.0