From patchwork Mon Apr 12 08:40:40 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: 419512 Delivered-To: patch@linaro.org Received: by 2002:a02:c4d2:0:0:0:0:0 with SMTP id h18csp1559832jaj; Mon, 12 Apr 2021 01:57:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZiyef/8LZmeSkUYybbAhPxlnslPJ+FwY2b8uRqG+zd+6sq8Fnetw0KsF/HlUYIl+j0eFV X-Received: by 2002:a62:7e41:0:b029:249:287:3706 with SMTP id z62-20020a627e410000b029024902873706mr10801599pfc.76.1618217860524; Mon, 12 Apr 2021 01:57:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618217860; cv=none; d=google.com; s=arc-20160816; b=IYFb6iQlcax8A9UVJUTy3eg8k4rBOIpkZQvnTAT1zoPphAkmbrb1zYcM0nF6tYlkzm tfdtLtUWbJbeftwpR5Kj5dcCA4J4K9xpVqW98HkixI1wMdnzP8uHn6UeiMFQTW3C96jD k8GsaQJbMZrmxd03XSo5UAZJFkIBM+DbmZYgbxEv4sG1wQc8kMr/6D0bUQ5W5w9Tgjvx +WEfoprtrDayFjcKFnY/CiBbe7Co7caT8MqnI4pUu4yWOhGrj687eg5PoAKO+tRAWTSZ lb3iR9JCOTaRgm2968RO/CvPeRZDhaP6gawFme17+i8ERlT80lyR67N6f8+WaAAWoCp7 lDjg== 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=W/tAB5QTt+973yyCEbs25R4+z5hab6HvwOKNm2wEFSg=; b=lZCbRHz6il9Qp7bsKd4uOU+c8RPGmmLjInyoudtl0v418fGHxfNp6fK4qctaI7UtqF qOSewcI0fj2Kb6a1qvf3D9vSiG/qXm4oFsYlX/aps/ZrvhOaGiKuaWb+uWU+8Mpqcz+I joifdQqV9D8IuWg0conI1O/mRd/WCIIp5CIyZDMbOjjdD9g7XMej5OzRuBrDbM/uCq2Q hA6H+aOiPEGnlgo/6L/MnjwWwe4qPV3GwFQQgnfyo8FU34GghGzNGyeYiFIG7r7Nu85A P18ngboYT71tOR1TvQhDTUmoCuSznMw+HPtpj6TuQc3r4NnbiHp+WyON1kg5bWo26fAI 5HRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wjp7CSzo; 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 t11si12307866pgl.74.2021.04.12.01.57.40; Mon, 12 Apr 2021 01:57:40 -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=Wjp7CSzo; 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 S238458AbhDLI5y (ORCPT + 12 others); Mon, 12 Apr 2021 04:57:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:49000 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238524AbhDLIzy (ORCPT ); Mon, 12 Apr 2021 04:55:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0060461221; Mon, 12 Apr 2021 08:55:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217736; bh=sVrCajMgdgNpzRj2BTgdDucVtkmO2lc2YYecXck1zLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wjp7CSzoLLtTWfUFxguVK4KzKTdb88HGiBN/FF4bHLgk8oyPMYnTGFUziZHhzfSAx j1XSV4s3T2ZSXIoQZ5pbTVCrRCPrd+yAzlBPXRj7hTtB+lqkOYbLtffef9Fe8nrCK/ UKZgBrQ1dBFwl9yKaJBK3nbqmgYqZEcJumgLtPpQ= 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.10 126/188] net: qrtr: Fix memory leak on qrtr_tx_wait failure Date: Mon, 12 Apr 2021 10:40:40 +0200 Message-Id: <20210412084017.836981182@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084013.643370347@linuxfoundation.org> References: <20210412084013.643370347@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 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);