Skip to content

Commit

Permalink
net: qrtr: Fix memory leak on qrtr_tx_wait failure
Browse files Browse the repository at this point in the history
qrtr_tx_wait does not check for radix_tree_insert failure, causing
the 'flow' object to be unreferenced after qrtr_tx_wait return. Fix
that by releasing flow on radix_tree_insert failure.

Fixes: 5fdeb0d ("net: qrtr: Implement outgoing flow control")
Reported-by: [email protected]
Signed-off-by: Loic Poulain <[email protected]>
Reviewed-by: Bjorn Andersson <[email protected]>
Reviewed-by: Manivannan Sadhasivam <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Loic Poulain authored and davem330 committed Mar 30, 2021
1 parent 6855e82 commit 8a03dd9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion net/qrtr/qrtr.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ static int qrtr_tx_wait(struct qrtr_node *node, int dest_node, int dest_port,
flow = kzalloc(sizeof(*flow), GFP_KERNEL);
if (flow) {
init_waitqueue_head(&flow->resume_tx);
radix_tree_insert(&node->qrtr_tx_flow, key, flow);
if (radix_tree_insert(&node->qrtr_tx_flow, key, flow)) {
kfree(flow);
flow = NULL;
}
}
}
mutex_unlock(&node->qrtr_tx_lock);
Expand Down

0 comments on commit 8a03dd9

Please sign in to comment.