net: qrtr: free memory on error path in radix_tree_insert()

Function radix_tree_insert() returns errors if the node hasn't
been initialized and added to the tree.

"kfree(node)" and return value "NULL" of node_get() help
to avoid using unclear node in other calls.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Cc: <[email protected]> # 5.7
Fixes: 0c2204a4ad ("net: qrtr: Migrate nameservice to kernel from userspace")
Signed-off-by: Natalia Petrova <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Reviewed-by: Manivannan Sadhasivam <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
This commit is contained in:
Natalia Petrova authored and Jakub Kicinski committed 2023-01-28 00:21:32 -08:00
1 parent 14caefcf98
commit 29de68c2b3
1 file changed
+4 -1
+4 -1
View File
@@ -83,7 +83,10 @@ static struct qrtr_node *node_get(unsigned int node_id)
node->id = node_id;
radix_tree_insert(&nodes, node_id, node);
if (radix_tree_insert(&nodes, node_id, node)) {
kfree(node);
return NULL;
}
return node;
}