Commit 29de68c2 authored by Natalia Petrova's avatar Natalia Petrova Committed by Jakub Kicinski

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: <stable@vger.kernel.org> # 5.7
Fixes: 0c2204a4 ("net: qrtr: Migrate nameservice to kernel from userspace")
Signed-off-by: default avatarNatalia Petrova <n.petrova@fintech.ru>
Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
Reviewed-by: default avatarManivannan Sadhasivam <mani@kernel.org>
Link: https://lore.kernel.org/r/20230125134831.8090-1-n.petrova@fintech.ruSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 14caefcf
...@@ -83,7 +83,10 @@ static struct qrtr_node *node_get(unsigned int node_id) ...@@ -83,7 +83,10 @@ static struct qrtr_node *node_get(unsigned int node_id)
node->id = 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; return node;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment