Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3692304ybv; Mon, 10 Feb 2020 04:48:49 -0800 (PST) X-Google-Smtp-Source: APXvYqw4zoXHgzO2NQ7RZGclHNPBsLGCjrX6oiOiHV1w1ZiDCWcv0hiJaLQDnlTCSS5lGw3dqf1j X-Received: by 2002:a9d:7509:: with SMTP id r9mr890517otk.270.1581338929368; Mon, 10 Feb 2020 04:48:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581338929; cv=none; d=google.com; s=arc-20160816; b=TyahefK7QTiUg6EvPwuDbg2lIrOzdR+jpRFPVYq0rKf+zVmMbdUz2lXiPC8iiac7SA 7Ra3uLT6AMyITcEcHK7UO9R4y5duoD24FrjZdtJnc+c//iSpSpTmc0CEQgwj0ufY/aeH ueC7XxjKBJ+3QpA77+RiHwVmHYeaSmfg1tIwmmAAaSDsf/jkiKKuM59AxSiV2OkKDi7u g8AhMgrkJduiyt8xx+6wMi45D4B0fNnXI+GW8PwDQwxrhRAnJ61V92yqQfIxMQ0HTt7M ppZfmyZaygDLuHi8RBonfVXddaNaMzLtQ8mUYthBEID07vMOwkWvE9GNxxWSSTbx9CWX LyeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5l2nnG0AWNal7SfME86nVc/5dSu7kvda+n8B2ESbshY=; b=A4otvPlKE+ftKKitHMD/qR08Wl5/N/12UA8pgoD6Ejc14hMCpHcl1qL6trlGjU4Qks QqL+OPSXP7yO+Hk47wOwWGhllKqtyL6yANpP0ntPl3nGFf7Hx6wn27zrPnKdGlQrpZsM hvM9YUHkvHXmsqkz+6DVcnMJcUv2aJS4zLwx8mqmarSyFllLL11shlkAHbCMrQeroN97 iXBDoSC7G/elG/sOLjUbEzMD8BUeNnQfcNfxv9ab9CazZrwkEnq/9HkPb64jssV1Rc/3 sCy4N+GGXWbqrAc7Ft0An/d0nDCLdvHY7Fi5oCvjcN5Ko22nmVs46HcdutflYaF/oaSN c8yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QrBfNGS9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m24si145385otn.67.2020.02.10.04.48.38; Mon, 10 Feb 2020 04:48:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QrBfNGS9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730806AbgBJMrB (ORCPT + 99 others); Mon, 10 Feb 2020 07:47:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:45274 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728349AbgBJMl4 (ORCPT ); Mon, 10 Feb 2020 07:41:56 -0500 Received: from localhost (unknown [209.37.97.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 677402080C; Mon, 10 Feb 2020 12:41:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338515; bh=Lu+RMBiy9nR3yqs0q6WNjeJ7PwjCRs6U+ml8VsoublY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QrBfNGS9XAMaWwKgSISqfGoSqjBdXepZcWuakSlAnCRBghT6GnU9WCwge90bdgCuG k4vVrEwie5bscRWfBDiAlaDchvqDS90SAj7k7kvHVLRFDgYIZOJpWRbMcp1dlYrjPj IpV+s/A4NDXOq7LSHneRflzAw4CxFtXX1SFZDOxg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jakub Kicinski , Jamal Hadi Salim , Jiri Pirko , Cong Wang , "David S. Miller" Subject: [PATCH 5.5 323/367] net_sched: fix a resource leak in tcindex_set_parms() Date: Mon, 10 Feb 2020 04:33:56 -0800 Message-Id: <20200210122452.808742927@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Cong Wang [ Upstream commit 52b5ae501c045010aeeb1d5ac0373ff161a88291 ] Jakub noticed there is a potential resource leak in tcindex_set_parms(): when tcindex_filter_result_init() fails and it jumps to 'errout1' which doesn't release the memory and resources allocated by tcindex_alloc_perfect_hash(). We should just jump to 'errout_alloc' which calls tcindex_free_perfect_hash(). Fixes: b9a24bb76bf6 ("net_sched: properly handle failure case of tcf_exts_init()") Reported-by: Jakub Kicinski Cc: Jamal Hadi Salim Cc: Jiri Pirko Signed-off-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sched/cls_tcindex.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/net/sched/cls_tcindex.c +++ b/net/sched/cls_tcindex.c @@ -365,7 +365,7 @@ tcindex_set_parms(struct net *net, struc err = tcindex_filter_result_init(&new_filter_result, net); if (err < 0) - goto errout1; + goto errout_alloc; if (old_r) cr = r->res; @@ -484,7 +484,6 @@ errout_alloc: tcindex_free_perfect_hash(cp); else if (balloc == 2) kfree(cp->h); -errout1: tcf_exts_destroy(&new_filter_result.exts); errout: kfree(cp);