[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210330151511.GE904837@yoga>
Date: Tue, 30 Mar 2021 10:15:11 -0500
From: Bjorn Andersson <bjorn.andersson@...aro.org>
To: Loic Poulain <loic.poulain@...aro.org>
Cc: manivannan.sadhasivam@...aro.org, netdev@...r.kernel.org,
kuba@...nel.org, davem@...emloft.net
Subject: Re: [PATCH] net: qrtr: Fix memory leak on qrtr_tx_wait failure
On Tue 30 Mar 09:11 CDT 2021, Loic Poulain wrote:
> 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@...kaller.appspotmail.com
> Signed-off-by: Loic Poulain <loic.poulain@...aro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@...aro.org>
Regards,
Bjorn
> ---
> net/qrtr/qrtr.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
> index f4ab3ca6..a01b50c7 100644
> --- a/net/qrtr/qrtr.c
> +++ b/net/qrtr/qrtr.c
> @@ -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);
> --
> 2.7.4
>
Powered by blists - more mailing lists