Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2138045pxb; Mon, 12 Apr 2021 15:43:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNicOdDUn3L0NcjAIIcCBu28jUghSxjZUiALYYNvIHptf+2K3nsa4y0WW8vzr2OPJzixLr X-Received: by 2002:a17:902:9685:b029:e9:abc1:7226 with SMTP id n5-20020a1709029685b02900e9abc17226mr19690377plp.64.1618267435906; Mon, 12 Apr 2021 15:43:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618267435; cv=none; d=google.com; s=arc-20160816; b=jdVbohSic8swvr2FUs9SrGhvHhq0N4GPwOIsNP1SZO8xt9Y+rxna9eRo3cm/OyPy4D j5EE/jFl+1oK6P7UkYcXsyLJc73gJ1qBtCXfVSY6tj3T4EAQ/PWpZ+7vA+9jT+QI57Yk 7slEGWgdKeVL+GiMJsGy2kTavQHm0IFmwe6/hI0Lkpo6LTpihSiEWXl0MqCXb9XWaTln eBXZX68u+fdfrmlSGGiushPPHVKupbk9ik6u2bBHwqGJcz8brA8LrYipuCB72Jqu+6PD 8uN3eJG1eXuaZ/+u2tJBCr14/lwWcevub75YVqZV59i/iTNcG7oolwjWq2z0oY1PzCKr 28kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XK1w0JTmLWV7F2W8MONntYM/Qzn/ZOn3x+v1E7QJjkw=; b=ohkaUotYZTyBREpuzVKLb0Wny7CjxxFJ0B+FUQGFEOmdhoWoK0DLtAfdPxaNWET33R D5TguGow0GZBMLNX+yPT1IRmSO8uSnDJPD4cvBusaxZaAWOXlRBh4cpCvX+Mp03CuSst TKBYntfNfeRQTtQibsE5p1KyKuzj3UHlhlY9NtMn6nChsmZVUL3KVfkzYc4Yv+Briwz+ wEUGFtYUsAPaBLMorsCyw8PpciE5Mr6HYfZoVBKwsbTvzfubnw51UjMoB0RHIbQThqnJ 91mZj7Z0Y3RamQoFzTeoVCKl0mPu5jRB6v6Jun8Z07dfN2pTZsNFu275qg7yLx2TiwPO X1yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kw3TWSMF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m4si15800719pgs.500.2021.04.12.15.43.41; Mon, 12 Apr 2021 15:43:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kw3TWSMF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240515AbhDLJeM (ORCPT + 99 others); Mon, 12 Apr 2021 05:34:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:34520 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239465AbhDLJJL (ORCPT ); Mon, 12 Apr 2021 05:09:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D7A1F61369; Mon, 12 Apr 2021 09:04:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618218277; bh=cvQws4cmnXa4LsKc8McTG7b2HYFdAr2HujD3qGe/cGg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kw3TWSMFbKRfnkVJSRlha+vBrysylmgCibYjxMuYIvRVqgRBppbGLMAI9YBVpmUML 9TwO5ZGs1OK0j5FPFWFR+nAvmMG2b7VZjb43sepereH+Av8p5BMGZJMUYZJn6cCy9I EoXTzlfF6bN83ABy4avEia9KcJTDL75UIWFMTHLc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+739016799a89c530b32a@syzkaller.appspotmail.com, Loic Poulain , Bjorn Andersson , Manivannan Sadhasivam , "David S. Miller" , Sasha Levin Subject: [PATCH 5.11 138/210] net: qrtr: Fix memory leak on qrtr_tx_wait failure Date: Mon, 12 Apr 2021 10:40:43 +0200 Message-Id: <20210412084020.596002938@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084016.009884719@linuxfoundation.org> References: <20210412084016.009884719@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Loic Poulain [ 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 Reviewed-by: Bjorn Andersson Reviewed-by: Manivannan Sadhasivam Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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 dfc820ee553a..1e4fb568fa84 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.30.2