Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1853609ybn; Thu, 26 Sep 2019 03:14:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJrzbAI6p90KqYAUvbIugm7o/dt9lSh8o/U8roEWU7lrvNVWv/DvKyJQHJ2LC//pv0PW3U X-Received: by 2002:a17:906:1cc6:: with SMTP id i6mr2376989ejh.40.1569492870849; Thu, 26 Sep 2019 03:14:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569492870; cv=none; d=google.com; s=arc-20160816; b=M3dplkc2il/2xxIGjFmNigDltdTtplIB2oxONZNvdy//5ykvZojO3mBvve4eEC8w1G gj5PqOZ3S+XW3oGRWXfDmftPjKRNSzohNbCTBkMDqLD20WC4WXpXUDvp+6aQcDnJ6o+f 5ILEU/XFUJQXqerNAvi+a+imbqvHeVKvriznz4Tbsg/HLp4d31ksNVumVY6Y/VcENdlh mVZJPYpXg0LYlZpDqHWo7oCU8uuEdDNAjobSjQT/oPZPZoVodk30VOZWl04ayAm4O6xi hofZXPN531lS9m2hPeVkjr6SEmdwPgr8zJ3ymiU2QkN/tFHT0z7w2wJLDJ65AXpbGY3x 1dhA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=j12YR8Sz7lqAWk3kVJllB0GpgeIbUZ8LPBlsVactf4o=; b=NaDAAvavr2Yszbif9yPN6YIy/3gX8xhGTKggJtOnsFaSonwqaaKg2YWeN0y/INjtcD zSgAKzwWo50hIjYF5lF5jwyZ6sTKNhXyNMT01jqzF3wWADaDpXMiLi32cEiiBTQBKPzp P7tPT/F1OIn9kYxz9ic2dS05nBebvKGodmwpW0padpi6RDcz6WqUKE8NgLGu2+NqA+F/ 2wwA7QE64sQ6cnulk5LZzhUevxqZrB9xIzVq/TbjozCHoJ2mR9d4Nc1HSuVGzPUw9puk I9lTsKhAmxaxcN4p9aZoPLECETB3h0GJo5IHhHL50ubl1uEJw2az4DmlY+4jov1/kTnX LcbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=MT974R0a; 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 m55si1042430edc.17.2019.09.26.03.14.07; Thu, 26 Sep 2019 03:14:30 -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=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=MT974R0a; 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 S2388878AbfIZB2v (ORCPT + 99 others); Wed, 25 Sep 2019 21:28:51 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:42845 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726707AbfIZB2u (ORCPT ); Wed, 25 Sep 2019 21:28:50 -0400 Received: by mail-pg1-f195.google.com with SMTP id z12so453256pgp.9 for ; Wed, 25 Sep 2019 18:28:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=j12YR8Sz7lqAWk3kVJllB0GpgeIbUZ8LPBlsVactf4o=; b=MT974R0a+7BOZEwbuehQtp8dBN4m9x82wscvv6hWcyd5Vz/4vnx3Wk+7Gs6qtKLzBC CxDEIKCBB+/MvaFjA0jVW2eWjbtY7fL5u0P6FfbLWSdG8HQUewhfMsft18SOo7RaGsL6 hJYxUcpEB1qLwaWv3s6Vir6AWd0Zx+k7VzGS49BPb+XV7EovyKrWxgtyvkM0HyHmskuP swRXdYKd2XVAlvN+psnPqQuZh5c0n5ukyzBQnyy1opB0bBXw6LyKDrJXuJQvEAKYHLGB t8y0EaKcQULXzpOZZ1FnfzhF0kRunBD6phEhpTKgWoIHSMxw6iREXSFyRvpJ8B4Gw3QL WHvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=j12YR8Sz7lqAWk3kVJllB0GpgeIbUZ8LPBlsVactf4o=; b=aq4RH2dbD9GY9t7xzxuV4p1Lp4d2LKjZfWVqYpzGdXfo5/bsWUaJei3ypbPMWiYzc/ IoQaykd2l6eQgR5oHHoMt0lH3UlJWQEfY939HVk9L3Gq4KY+faBNfSogIPmW+MhoAsbL LyUl5uEI2BTRamDd/b0S0XwJPyiGTpzd3prSVQscejWEqzilQQ9RF/g/Q8lVglQ5Q6y+ SRVkfBArF5A4t15e/hJOj/HRh/OeLUfBUjXdJHD8xsArC7DitxDs/XAav47nI1+ncDbt fEOVdBE+I/mxdgX41kQZGU4N8LSFxY7jWolg+p+WKNanMjO+UhZomE25QAZ162BU5IwA rUcw== X-Gm-Message-State: APjAAAXvKP+tzRS3seJ46FpdNMwAxlEC8kA3X+RKLy9LFP/7KSl4dj85 5ngDSY7he9PSB7yDps2GmFPCXQ== X-Received: by 2002:a62:1e82:: with SMTP id e124mr789701pfe.136.1569461330070; Wed, 25 Sep 2019 18:28:50 -0700 (PDT) Received: from cakuba.netronome.com (c-73-202-202-92.hsd1.ca.comcast.net. [73.202.202.92]) by smtp.gmail.com with ESMTPSA id h4sm256255pfg.159.2019.09.25.18.28.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 18:28:49 -0700 (PDT) Date: Wed, 25 Sep 2019 18:28:46 -0700 From: Jakub Kicinski To: Navid Emamdoost Cc: emamd001@umn.edu, smccaman@umn.edu, kjlu@umn.edu, "David S. Miller" , Pablo Neira Ayuso , Colin Ian King , oss-drivers@netronome.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: flow_offload: fix memory leak in nfp_abm_u32_knode_replace Message-ID: <20190925182846.69a261e8@cakuba.netronome.com> In-Reply-To: <20190925183457.32695-1-navid.emamdoost@gmail.com> References: <20190925183457.32695-1-navid.emamdoost@gmail.com> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 25 Sep 2019 13:34:46 -0500, Navid Emamdoost wrote: > In nfp_abm_u32_knode_replace if the allocation for match fails it should > go to the error handling instead of returning. > > Signed-off-by: Navid Emamdoost > --- > drivers/net/ethernet/netronome/nfp/abm/cls.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/ethernet/netronome/nfp/abm/cls.c b/drivers/net/ethernet/netronome/nfp/abm/cls.c > index 23ebddfb9532..32eaab99d96c 100644 > --- a/drivers/net/ethernet/netronome/nfp/abm/cls.c > +++ b/drivers/net/ethernet/netronome/nfp/abm/cls.c > @@ -174,7 +174,7 @@ nfp_abm_u32_knode_replace(struct nfp_abm_link *alink, > struct nfp_abm_u32_match *match = NULL, *iter; > unsigned int tos_off; > u8 mask, val; > - int err; > + int err, ret = -EOPNOTSUPP; You can use the err variable for the return. Please don't break the reverse christmas tree ordering. Please initialize the err variable in the branch where failure occurred, not at the start of the function. > if (!nfp_abm_u32_check_knode(alink->abm, knode, proto, extack)) > goto err_delete; > @@ -204,8 +204,11 @@ nfp_abm_u32_knode_replace(struct nfp_abm_link *alink, > > if (!match) { > match = kzalloc(sizeof(*match), GFP_KERNEL); > - if (!match) > - return -ENOMEM; > + if (!match) { > + ret = -ENOMEM; > + goto err_delete; > + } > + > list_add(&match->list, &alink->dscp_map); > } > match->handle = knode->handle; > @@ -221,7 +224,7 @@ nfp_abm_u32_knode_replace(struct nfp_abm_link *alink, > > err_delete: > nfp_abm_u32_knode_delete(alink, knode); > - return -EOPNOTSUPP; > + return ret; > } > > static int nfp_abm_setup_tc_block_cb(enum tc_setup_type type,