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/sdk6.1~71 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=95a2adfd2ec0234a70fd720e628b8d9a6aa1e326;p=kernel.git interconnect: fix mem leak when freeing nodes commit 080fb54c5f0e856316ca6bb00a35416eeee54093 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 1e814d382d4a6..cfa52c6369d05 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -850,6 +850,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);