From patchwork Thu May 8 09:40:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tingwei Liu X-Patchwork-Id: 346959 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id A488514007A for ; Thu, 8 May 2014 19:41:10 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754026AbaEHJlE (ORCPT ); Thu, 8 May 2014 05:41:04 -0400 Received: from mail-yh0-f44.google.com ([209.85.213.44]:39739 "EHLO mail-yh0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753901AbaEHJk6 (ORCPT ); Thu, 8 May 2014 05:40:58 -0400 Received: by mail-yh0-f44.google.com with SMTP id b6so2060743yha.31 for ; Thu, 08 May 2014 02:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=hEdlJ5Oc5n2ia912/tK2G3Qe9fILsUKL1ecxfQBTQv8=; b=rgVe4YezjPWGI3qiGCLeWAn4p68dY8fGCkHxBo6qk3CuK2YkSYwShIAHy/euQLJjJX AZ8DGxAwRJrjBA8geyjnXSqc1qKcQdsZhLR68BuycIiqOMP49nY+73OQfGVWNqBHERAS AV0Lgy5OfxKDzgWXzsYqvN80WjtJIJ4xXtouleEpqDHWzXobmfloF0mA13tDXZrwiTsz sb8uoDSSsChCLUdTXlOax6uAMjV9pTbmHbD3CmQkg5TY1EP4kmLQ23CISo/a2WqRa357 sW9vt4UBabfs48BR2IaRDOGOST510trejG9/Rs2aQW+MhFx/G9dwtK+T/LAmoYsw3VQ1 XHNg== MIME-Version: 1.0 X-Received: by 10.236.91.67 with SMTP id g43mr3375097yhf.146.1399542058020; Thu, 08 May 2014 02:40:58 -0700 (PDT) Received: by 10.170.148.197 with HTTP; Thu, 8 May 2014 02:40:57 -0700 (PDT) In-Reply-To: <536B3859.2050908@huawei.com> References: <536B3859.2050908@huawei.com> Date: Thu, 8 May 2014 17:40:57 +0800 Message-ID: Subject: Re: [PATCH net-next] sctp: add a checking for sctp_sysctl_net_register From: tingwei liu To: Wang Weidong Cc: David Miller , Vlad Yasevich , Neil Horman , Daniel Borkmann , linux-sctp@vger.kernel.org, netdev@vger.kernel.org, Tony Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, May 8, 2014 at 3:55 PM, Wang Weidong wrote: > When register_net_sysctl failed, we should free the > sysctl_table while the net_namespace is not init_net. > > Signed-off-by: Wang Weidong > --- > net/sctp/sysctl.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c > index 844d2b0..4c17694 100644 > --- a/net/sctp/sysctl.c > +++ b/net/sctp/sysctl.c > @@ -450,6 +450,11 @@ int sctp_sysctl_net_register(struct net *net) > } > > net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table); > + if (net->sctp.sysctl_header == NULL) { > + if (!net_eq(net, &init_net)) > + kfree(table); > + return -ENOMEM; > + } > return 0; > } > Hope to resolve the problem of sctp_sysctl_net_unregister() in one patch! kfree(table) should check net namesapce. Thanks Tingwei Liu > -- > 1.7.12 > > > -- > To unsubscribe from this list: send the line "unsubscribe netdev" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c index c82fdc1..844d2b0 100644 --- a/net/sctp/sysctl.c +++ b/net/sctp/sysctl.c @@ -459,7 +459,8 @@ void sctp_sysctl_net_unregister(struct net *net) table = net->sctp.sysctl_header->ctl_table_arg; unregister_net_sysctl_table(net->sctp.sysctl_header); - kfree(table); + if (!net_eq(net, &init_net)) + kfree(table); } static struct ctl_table_header *sctp_sysctl_header;