Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

interconnect: icc-clk: destroy nodes in case of memory allocation failures

When memory allocation fails during creating the name of the nodes in
icc_clk_register(), the code continues on the error path and it calls
icc_nodes_remove() to destroy the already created nodes. However that
function only destroys the nodes which were already added to the provider
and the newly created nodes are never destroyed in case of error.

In order to avoid a memory leaks, change the code to destroy the newly
created nodes explicitly in case of memory allocation failures.

Fixes: 44c5aa73ccd1 ("interconnect: icc-clk: check return values of devm_kasprintf()")
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Link: https://lore.kernel.org/r/20250625-icc-clk-memleak-fix-v1-1-4151484cd24f@gmail.com
Signed-off-by: Georgi Djakov <djakov@kernel.org>

authored by

Gabor Juhos and committed by
Georgi Djakov
618c810a 1809db75

+2
+2
drivers/interconnect/icc-clk.c
··· 117 117 118 118 node->name = devm_kasprintf(dev, GFP_KERNEL, "%s_master", data[i].name); 119 119 if (!node->name) { 120 + icc_node_destroy(node->id); 120 121 ret = -ENOMEM; 121 122 goto err; 122 123 } ··· 136 135 137 136 node->name = devm_kasprintf(dev, GFP_KERNEL, "%s_slave", data[i].name); 138 137 if (!node->name) { 138 + icc_node_destroy(node->id); 139 139 ret = -ENOMEM; 140 140 goto err; 141 141 }