Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2987413ybi; Thu, 18 Jul 2019 18:45:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxoQsFcuiBXzSwfOUpBazL1zp4nnwgCvHS9ktFeRV+WLFT7I0IOEaab9W0PBlDjpb4sout0 X-Received: by 2002:a17:902:1101:: with SMTP id d1mr8951077pla.212.1563500715267; Thu, 18 Jul 2019 18:45:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563500715; cv=none; d=google.com; s=arc-20160816; b=E/uZBvbPqSvVxuN/p6mMG8E3gWTaRvFQ+iEIcYqrIIZOFRSYpaVmySFM/IZL4Ftn/0 zs/dxcwLIDsVj1y+YB9AZMgd2ku2oA8/BY9c5/aBuDBBM6p29HAlgqiuBOFd1E5isc0n EI1m/EonuvWWmaTtCxlW6PitzAQP8mXHJ/VMPRXM4JAMFI+1Hx31ekK7UU0SK0Bohcui BijPTVqjRpXcQxINj34B/r7fbA5vHcAARoAA+878jmRCoYGXlsup0kiBLGHiOVLYr6v4 //cGL/Pu2xWgxvbBztbm9ST40GNKGFDbXGdwKVbQqZMHf0pZiI6z7X5U6RUz//y/CnbK q6JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=4MpWyzy28UADS2rG6UYZlk7olTDpvA6s9sPL020OM9A=; b=jPadFv1EUdQgKn8DHpZxq8GkisauXZY2dxfCJRFudVGIRd0CTd2WIIUBtLoT+QobDp cxhurMtmXk3cHmGNn7JhklDxwZRI0pbamMT5ATGLPQppbpgcAFaHaRtr9ICSp1DuzuZx jv3pMxedcC6oVGEeSIl8qiBdb/UzMbUYUTXgu20e3fun9yUTMMxsNiMPAHuttdg9HyaX fzQDz7+yiuQxW97x543XmkfXBq7s0FDgByWpTkHo/bwj8CHfC4TGRDYw11RaArNjoVQL kvhos0oP2np3S3ucbL56lStvvFymUPV+dv8eY8MewlSRn410uBi0UKc3qWdpaF+6oU2Y mW7A== ARC-Authentication-Results: i=1; mx.google.com; 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 bh2si856860plb.116.2019.07.18.18.44.59; Thu, 18 Jul 2019 18:45:15 -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; 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 S1726462AbfGSBoT convert rfc822-to-8bit (ORCPT + 99 others); Thu, 18 Jul 2019 21:44:19 -0400 Received: from cmccmta3.chinamobile.com ([221.176.66.81]:15176 "EHLO cmccmta3.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726072AbfGSBoS (ORCPT ); Thu, 18 Jul 2019 21:44:18 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.1]) by rmmx-syy-dmz-app11-12011 (RichMail) with SMTP id 2eeb5d312054c02-a8005; Fri, 19 Jul 2019 09:43:49 +0800 (CST) X-RM-TRANSID: 2eeb5d312054c02-a8005 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from [172.20.21.101] (unknown[112.25.154.148]) by rmsmtp-syy-appsvr01-12001 (RichMail) with SMTP id 2ee15d31205337a-2e74a; Fri, 19 Jul 2019 09:43:48 +0800 (CST) X-RM-TRANSID: 2ee15d31205337a-2e74a Content-Type: text/plain; charset=gb2312 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [PATCH] openvswitch: Fix a possible memory leak on dst_cache From: Haishuang Yan In-Reply-To: <9b231232-dd6e-5733-2af9-e2fb3d6ae0a4@gmail.com> Date: Fri, 19 Jul 2019 09:43:47 +0800 Cc: Pravin B Shelar , "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: References: <1563466028-2531-1-git-send-email-yanhaishuang@cmss.chinamobile.com> <9b231232-dd6e-5733-2af9-e2fb3d6ae0a4@gmail.com> To: Gregory Rose X-Mailer: Apple Mail (2.3273) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On 2019??7??19??, at ????6:12, Gregory Rose wrote: > > On 7/18/2019 9:07 AM, Haishuang Yan wrote: >> dst_cache should be destroyed when fail to add flow actions. >> >> Fixes: d71785ffc7e7 ("net: add dst_cache to ovs vxlan lwtunnel") >> Signed-off-by: Haishuang Yan >> --- >> net/openvswitch/flow_netlink.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c >> index d7559c6..1fd1cdd 100644 >> --- a/net/openvswitch/flow_netlink.c >> +++ b/net/openvswitch/flow_netlink.c >> @@ -2608,6 +2608,7 @@ static int validate_and_copy_set_tun(const struct nlattr *attr, >> sizeof(*ovs_tun), log); >> if (IS_ERR(a)) { >> dst_release((struct dst_entry *)tun_dst); >> + dst_cache_destroy(&tun_dst->u.tun_info.dst_cache); >> return PTR_ERR(a); >> } >> > > Nack. > > dst_release will decrement the ref count and will call_rcu(&dst->rcu_head, dst_destroy_rcu) if the ref count is zero. No other net drivers call dst_destroy SFAICT. > > Haishuang, > > are you trying to fix some specific problem here? > > Thanks, > > - Greg > > Greg, You??re right, dst_cache would be freed in metadata_dst_free: 125 126 if (dst->flags & DST_METADATA) 127 metadata_dst_free((struct metadata_dst *)dst); 128 else 129 kmem_cache_free(dst->ops->kmem_cachep, dst); 130 I thought I encountered a memory leak, but it seems not an issue, thanks for you explanation.