]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
soc: qcom: aoss: Fix the out of bound usage of cooling_devs
authorManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Tue, 29 Jun 2021 15:32:49 +0000 (21:02 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Sep 2021 11:41:45 +0000 (13:41 +0200)
commit6e65b02044b9b12a9b39cebdbe4c2f556f94d283
treec3c67d9e400eae5c2e1c48805204347a2eeacbb4
parent013842896512a1efbcb0dfce5df4cb0f088ddd79
soc: qcom: aoss: Fix the out of bound usage of cooling_devs

commit a89f355e469dcda129c2522be4fdba00c1c74c83 upstream.

In "qmp_cooling_devices_register", the count value is initially
QMP_NUM_COOLING_RESOURCES, which is 2. Based on the initial count value,
the memory for cooling_devs is allocated. Then while calling the
"qmp_cooling_device_add" function, count value is post-incremented for
each child node.

This makes the out of bound access to the cooling_dev array. Fix it by
passing the QMP_NUM_COOLING_RESOURCES definition to devm_kzalloc() and
initializing the count to 0.

While at it, let's also free the memory allocated to cooling_dev if no
cooling device is found in DT and during unroll phase.

Cc: stable@vger.kernel.org # 5.4
Fixes: 05589b30b21a ("soc: qcom: Extend AOSS QMP driver to support resources that are used to wake up the SoC.")
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20210629153249.73428-1-manivannan.sadhasivam@linaro.org
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/soc/qcom/qcom_aoss.c