From: Johan Hovold Date: Mon, 6 Mar 2023 07:56:29 +0000 (+0100) Subject: interconnect: fix mem leak when freeing nodes X-Git-Tag: baikal/mips/sdk5.8.2~120 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=64a5263cfae112267ff0477a9dd01cce78efbbbf;p=kernel.git interconnect: fix mem leak when freeing nodes commit a5904f415e1af72fa8fe6665aa4f554dc2099a95 upstream. The node link array is allocated when adding links to a node but is not deallocated when nodes are destroyed. Fixes: 011f637d6b07 ("interconnect: Add generic on-chip interconnect API") Cc: stable@vger.kernel.org # 5.1 Reviewed-by: Konrad Dybcio Signed-off-by: Johan Hovold Tested-by: Luca Ceresoli # i.MX8MP MSC SM2-MB-EP1 Board Link: https://lore.kernel.org/r/20230306075651.2449-2-johan+linaro@kernel.org Signed-off-by: Georgi Djakov Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index e579b3633a842..e63c48a1602fd 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -612,6 +612,10 @@ void icc_node_destroy(int id) mutex_unlock(&icc_lock); + if (!node) + return; + + kfree(node->links); kfree(node); } EXPORT_SYMBOL_GPL(icc_node_destroy);