diff options
author | Loic Poulain <loic.poulain@linaro.org> | 2021-03-30 16:11:08 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-04-14 08:42:08 +0200 |
commit | 6af631d1caf25811fc2e6d60dd54200827a8f405 (patch) | |
tree | 759ba93884d085d5322d884f2a6409eda8f65a61 /net | |
parent | dfe7805e6aa6f54f7b01c3f11c23af938ad9bd7b (diff) | |
download | linux-stable-6af631d1caf25811fc2e6d60dd54200827a8f405.tar.gz linux-stable-6af631d1caf25811fc2e6d60dd54200827a8f405.tar.bz2 linux-stable-6af631d1caf25811fc2e6d60dd54200827a8f405.zip |
net: qrtr: Fix memory leak on qrtr_tx_wait failure
[ Upstream commit 8a03dd925786bdc3834d56ccc980bb70668efa35 ]
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: 5fdeb0d372ab ("net: qrtr: Implement outgoing flow control")
Reported-by: syzbot+739016799a89c530b32a@syzkaller.appspotmail.com
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/qrtr/qrtr.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index 45fbf5f4dcd2..93a7edcff11e 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -266,7 +266,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); |