From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH net-next 0/5] net: Consolidate metrics handling for ipv4 and ipv6 Date: Fri, 5 Oct 2018 09:37:23 -0600 Message-ID: <19a1e616-4597-cc01-1f13-e50c7366f304@gmail.com> References: <20181005030755.31217-1-dsahern@kernel.org> <20181004.215507.1973705600397352485.davem@davemloft.net> <2b4d849f-9bd3-28aa-7a1c-ad61ab584041@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, weiwan@google.com, sd@queasysnail.net, xiyou.wangcong@gmail.com To: Eric Dumazet , David Miller , dsahern@kernel.org Return-path: Received: from mail-pg1-f196.google.com ([209.85.215.196]:40014 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728606AbeJEWgk (ORCPT ); Fri, 5 Oct 2018 18:36:40 -0400 Received: by mail-pg1-f196.google.com with SMTP id n31-v6so4899667pgm.7 for ; Fri, 05 Oct 2018 08:37:27 -0700 (PDT) In-Reply-To: Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 10/5/18 7:08 AM, Eric Dumazet wrote: > Commit 767a2217533fed6 ("net: common metrics init helper for FIB entries") > is not correct because we need to better deal with error paths. > > I will submit this more formally when I can reach my workstation in a few minutes : > > diff --git a/net/ipv6/route.c b/net/ipv6/route.c > index 6c1d817151cae45421dc976c5ea082b4115650be..74d97addf1af20dda0c2b6a2018e88696f9f7d5a 100644 > --- a/net/ipv6/route.c > +++ b/net/ipv6/route.c > @@ -2976,6 +2976,8 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg, > rt->fib6_metrics = ip_fib_metrics_init(net, cfg->fc_mx, cfg->fc_mx_len); > if (IS_ERR(rt->fib6_metrics)) { > err = PTR_ERR(rt->fib6_metrics); > + /* Do not leave garbage there. */ > + rt->fib6_metrics = (struct dst_metrics *)&dst_default_metrics; > goto out; > } > > Yes, I was focused on the memory leaks and cleanup and forgot to purposely fail the alloc for the metrics. The above is one way to fix it. Thanks for spotting it.