Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2077896ybp; Thu, 10 Oct 2019 01:47:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzb9KpCoqT+GzO/+1UzMqtd34xj8vud7P9KUdOyKBqM5Q19qj2b1n4jJWKgCZqDklldv/hu X-Received: by 2002:a50:d615:: with SMTP id x21mr7060104edi.297.1570697248817; Thu, 10 Oct 2019 01:47:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697248; cv=none; d=google.com; s=arc-20160816; b=jTRsUKwR0EO8WvTIa0s2T20RvGBDiku8ZcBPXqWXNYQqAE9ZCM0bgGeWAEt1EluciB YfUSYoIAQgbz0v37qwjZ4TVMEjjOnQjf4uY1cjCyFuTSCGKuLd5CbPvPR27HtXAIUZlT VcwMO70NiL3VioopK6uABGH3eoCO1xxcw0gtbFb+5nBCJSd4wk4q4RL2Wo2Hdl1+hAwB esQFKuBjVsF9VEWKsblBBSmQdYoSXAh3lKjveZFk5SmL1y4HpwNUOOTKKy+CEbYM6NGR eElzx6kkuPSl3ucoqk7R+jnoXWjEK8xmSqfpdFiNEUjzxOhn/7zsb6jzK1F/HrLXygsL OXQw== 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=ebOsPNaF0cbAWN2aD88gddUjgcFwWzR33IDnI3b5sbA=; b=FSPLU3w4KHW2VEHsVYPyuUPxo14uu1hI2IkbDliZOInHxjuF+NQ3f30/FjTkFYu4n8 snfujn65Xsd2RwTLMTpVLHyHEKO9mv+HYlJjNpcKFz+beN+AsE86n04h4OpXp54ACy0q cl2XxyTGyvpOVwFMKsucabnrXk6n60+pf8ijhKpTRyNHzCctKYLyzxp51h1ORryjouE6 pgZJuhtivoloDFzwNBkArljapu0HfSlF1dHAemPNLFRuEVQsGKTE+U4MMGzc2RXOlgce jGL8OASvJWzpDEgyxN0Dz9kzX3y7NolURBs0qCOw5QYykpnteb5OemjtOq6/KtqWfWLq BSlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iHW89rmj; 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 e46si2731767eda.401.2019.10.10.01.47.05; Thu, 10 Oct 2019 01:47:28 -0700 (PDT) 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=iHW89rmj; 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 S2388936AbfJJIo0 (ORCPT + 99 others); Thu, 10 Oct 2019 04:44:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:49604 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388932AbfJJIoZ (ORCPT ); Thu, 10 Oct 2019 04:44:25 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 1E3042054F; Thu, 10 Oct 2019 08:44:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570697064; bh=o8YQWDq9izhWPzGb6JCcR7h6l1EMb//vReFY9UK3M6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iHW89rmjIzeQeY9royUtBl2WX5umbo/mLmFfVoBcygSxcNdPXoVc38CllcQSPZwKs 6LW6OJq2Z0p94mclJT6KmOIBv5H0VRjIggQNMmuEASF6x3uchVfG5E1Qk52xa3OoY2 BL6JTeiqbCshZvjXnUuUjlKAlj5qqqZU7F0BJffo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Navid Emamdoost , "David S. Miller" , Sasha Levin Subject: [PATCH 5.3 134/148] nfp: abm: fix memory leak in nfp_abm_u32_knode_replace Date: Thu, 10 Oct 2019 10:36:35 +0200 Message-Id: <20191010083620.492534065@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083609.660878383@linuxfoundation.org> References: <20191010083609.660878383@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: Navid Emamdoost [ Upstream commit 78beef629fd95be4ed853b2d37b832f766bd96ca ] In nfp_abm_u32_knode_replace if the allocation for match fails it should go to the error handling instead of returning. Updated other gotos to have correct errno returned, too. Signed-off-by: Navid Emamdoost Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/netronome/nfp/abm/cls.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/abm/cls.c b/drivers/net/ethernet/netronome/nfp/abm/cls.c index 23ebddfb95325..9f8a1f69c0c4c 100644 --- a/drivers/net/ethernet/netronome/nfp/abm/cls.c +++ b/drivers/net/ethernet/netronome/nfp/abm/cls.c @@ -176,8 +176,10 @@ nfp_abm_u32_knode_replace(struct nfp_abm_link *alink, u8 mask, val; int err; - if (!nfp_abm_u32_check_knode(alink->abm, knode, proto, extack)) + if (!nfp_abm_u32_check_knode(alink->abm, knode, proto, extack)) { + err = -EOPNOTSUPP; goto err_delete; + } tos_off = proto == htons(ETH_P_IP) ? 16 : 20; @@ -198,14 +200,18 @@ nfp_abm_u32_knode_replace(struct nfp_abm_link *alink, if ((iter->val & cmask) == (val & cmask) && iter->band != knode->res->classid) { NL_SET_ERR_MSG_MOD(extack, "conflict with already offloaded filter"); + err = -EOPNOTSUPP; goto err_delete; } } if (!match) { match = kzalloc(sizeof(*match), GFP_KERNEL); - if (!match) - return -ENOMEM; + if (!match) { + err = -ENOMEM; + goto err_delete; + } + list_add(&match->list, &alink->dscp_map); } match->handle = knode->handle; @@ -221,7 +227,7 @@ nfp_abm_u32_knode_replace(struct nfp_abm_link *alink, err_delete: nfp_abm_u32_knode_delete(alink, knode); - return -EOPNOTSUPP; + return err; } static int nfp_abm_setup_tc_block_cb(enum tc_setup_type type, -- 2.20.1