From patchwork Mon Apr 12 08:40:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 419519 Delivered-To: patch@linaro.org Received: by 2002:a02:c4d2:0:0:0:0:0 with SMTP id h18csp1569766jaj; Mon, 12 Apr 2021 02:13:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySIB+uSex83rCVVGQvs6u2Llr5Xh0k2taaN1F051hP3rNhO0dTxPdlwWbOTwqERCK7yvn1 X-Received: by 2002:a65:6255:: with SMTP id q21mr18472107pgv.382.1618218823773; Mon, 12 Apr 2021 02:13:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618218823; cv=none; d=google.com; s=arc-20160816; b=N3KT5bIMErZieLqXyL2sApKUBjsvDu9KF8IPMq60Ae82NbgOZCW/0NyfJNKsjj529G 1DGihek1rAuphDR2vxh8R34xZZ0puhfb3Wd0sE4X8Xoy4VcDPlCgHfuVQAb5CZ4T8tJo xtZt1OiLlYFP40TPW/hibiisbasWetFrsRr4OLTCwcn8KPgpS5zotgubX5KLkEUCGopM XJ4JS2hSNarlvUIrE5UH5zzdsmrPunT3NvXcNXO77HpQZo0ANTDj0hgOy9tNpkJpu1g9 ENRxRO16HEeS2HvDGSfbvohsJepTwLjiddg9B0QHv04PSf52t7amj4fVc5sIdDzv6htl Pnwg== 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=eBnyZcBHxO0GV+nlM1JrW78WQUVqoNSCMCOdewwicfR6cZK5D1n7BWWB16w8NYy78E yKdFDUmfSqCpPhw0kQ1JaqqMuBDsoMlWkKM1vT7KnntDObZY8Fo1kRM7u1xEWDkchsnX MEIAGmlh+KfZVifuDq+IuRUUd30Z4Y0F9IDmMadtapZC77K8Q7ceMhAVqbPrRQaK8Nm3 XrcV81yKC8uD3ZF3nJ5R2xdWdfAfdHMmGwEs6Cf3JjvaPBDHzawy3yFrZGXwUR+XBJDr C15EGvXAuREQyAp1jMcIZVzLsd8gaN258m/KBeGQTuS8hnVtsFL5tRC8k9w0dnl6z0DD qYDw== 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 stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 r15si12368322pga.317.2021.04.12.02.13.43; Mon, 12 Apr 2021 02:13:43 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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 stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 S239503AbhDLJND (ORCPT + 12 others); Mon, 12 Apr 2021 05:13:03 -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 Precedence: bulk List-ID: X-Mailing-List: stable@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(-) -- 2.30.2 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);