From patchwork Thu May 8 07:55:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wangweidong X-Patchwork-Id: 346917 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 5C7CC140081 for ; Thu, 8 May 2014 17:56:14 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753301AbaEHH4J (ORCPT ); Thu, 8 May 2014 03:56:09 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:18216 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752845AbaEHH4H (ORCPT ); Thu, 8 May 2014 03:56:07 -0400 Received: from 172.24.2.119 (EHLO szxeml205-edg.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BTN18313; Thu, 08 May 2014 15:55:30 +0800 (CST) Received: from SZXEML418-HUB.china.huawei.com (10.82.67.157) by szxeml205-edg.china.huawei.com (172.24.2.58) with Microsoft SMTP Server (TLS) id 14.3.158.1; Thu, 8 May 2014 15:55:08 +0800 Received: from [127.0.0.1] (10.177.18.75) by szxeml418-hub.china.huawei.com (10.82.67.157) with Microsoft SMTP Server id 14.3.158.1; Thu, 8 May 2014 15:55:06 +0800 Message-ID: <536B3859.2050908@huawei.com> Date: Thu, 8 May 2014 15:55:05 +0800 From: Wang Weidong User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: David Miller , Vlad Yasevich , Neil Horman CC: Daniel Borkmann , , Subject: [PATCH net-next] sctp: add a checking for sctp_sysctl_net_register X-Originating-IP: [10.177.18.75] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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; }