Skip to content

Commit 618c810

Browse files
juhosgGeorgi Djakov
authored andcommitted
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: 44c5aa7 ("interconnect: icc-clk: check return values of devm_kasprintf()") Signed-off-by: Gabor Juhos <[email protected]> Reviewed-by: Bartosz Golaszewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Georgi Djakov <[email protected]>
1 parent 1809db7 commit 618c810

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/interconnect/icc-clk.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ struct icc_provider *icc_clk_register(struct device *dev,
117117

118118
node->name = devm_kasprintf(dev, GFP_KERNEL, "%s_master", data[i].name);
119119
if (!node->name) {
120+
icc_node_destroy(node->id);
120121
ret = -ENOMEM;
121122
goto err;
122123
}
@@ -135,6 +136,7 @@ struct icc_provider *icc_clk_register(struct device *dev,
135136

136137
node->name = devm_kasprintf(dev, GFP_KERNEL, "%s_slave", data[i].name);
137138
if (!node->name) {
139+
icc_node_destroy(node->id);
138140
ret = -ENOMEM;
139141
goto err;
140142
}

0 commit comments

Comments
 (0)