diff options
author | Natalia Petrova <n.petrova@fintech.ru> | 2023-01-25 16:48:31 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-01-28 00:21:32 -0800 |
commit | 29de68c2b32ce58d64dea496d281e25ad0f551bd (patch) | |
tree | ffd972702cac2a34a6a48a86d2317d8a22984a19 /net/qrtr | |
parent | 14caefcf9837a2be765a566005ad82cd0d2a429f (diff) | |
download | linux-rpi-29de68c2b32ce58d64dea496d281e25ad0f551bd.tar.gz linux-rpi-29de68c2b32ce58d64dea496d281e25ad0f551bd.tar.bz2 linux-rpi-29de68c2b32ce58d64dea496d281e25ad0f551bd.zip |
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: 0c2204a4ad71 ("net: qrtr: Migrate nameservice to kernel from userspace")
Signed-off-by: Natalia Petrova <n.petrova@fintech.ru>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://lore.kernel.org/r/20230125134831.8090-1-n.petrova@fintech.ru
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/qrtr')
-rw-r--r-- | net/qrtr/ns.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/net/qrtr/ns.c b/net/qrtr/ns.c index 1990d496fcfc..e595079c2caf 100644 --- a/net/qrtr/ns.c +++ b/net/qrtr/ns.c @@ -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; } |