netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Loic Poulain <loic.poulain@linaro.org>
Cc: manivannan.sadhasivam@linaro.org, netdev@vger.kernel.org,
	kuba@kernel.org, davem@davemloft.net
Subject: Re: [PATCH] net: qrtr: Fix memory leak on qrtr_tx_wait failure
Date: Tue, 30 Mar 2021 10:15:11 -0500	[thread overview]
Message-ID: <20210330151511.GE904837@yoga> (raw)
In-Reply-To: <1617113468-19222-1-git-send-email-loic.poulain@linaro.org>

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@syzkaller.appspotmail.com
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.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
> 

  reply	other threads:[~2021-03-30 15:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-30 14:11 [PATCH] net: qrtr: Fix memory leak on qrtr_tx_wait failure Loic Poulain
2021-03-30 15:15 ` Bjorn Andersson [this message]
2021-03-30 17:09 ` Manivannan Sadhasivam
2021-03-30 20:50 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210330151511.GE904837@yoga \
    --to=bjorn.andersson@linaro.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=loic.poulain@linaro.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).