From patchwork Fri Dec 6 06:23:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wangweidong X-Patchwork-Id: 297591 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 AECF02C009F for ; Fri, 6 Dec 2013 17:24:15 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755228Ab3LFGYF (ORCPT ); Fri, 6 Dec 2013 01:24:05 -0500 Received: from szxga01-in.huawei.com ([119.145.14.64]:45070 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756193Ab3LFGX7 (ORCPT ); Fri, 6 Dec 2013 01:23:59 -0500 Received: from 172.24.2.119 (EHLO szxeml206-edg.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BNX31251; Fri, 06 Dec 2013 14:23:51 +0800 (CST) Received: from SZXEML421-HUB.china.huawei.com (10.82.67.160) by szxeml206-edg.china.huawei.com (172.24.2.59) with Microsoft SMTP Server (TLS) id 14.3.158.1; Fri, 6 Dec 2013 14:23:46 +0800 Received: from localhost (10.135.68.79) by szxeml421-hub.china.huawei.com (10.82.67.160) with Microsoft SMTP Server id 14.3.158.1; Fri, 6 Dec 2013 14:23:47 +0800 From: Wang Weidong To: , , CC: , Subject: [PATCH net-next 6/6] tipc: separate the check nseq and sseq allocate failed Date: Fri, 6 Dec 2013 14:23:42 +0800 Message-ID: <1386311022-11176-7-git-send-email-wangweidong1@huawei.com> X-Mailer: git-send-email 1.8.1.msysgit.1 In-Reply-To: <1386311022-11176-1-git-send-email-wangweidong1@huawei.com> References: <1386311022-11176-1-git-send-email-wangweidong1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.135.68.79] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org if nseq allocate failed, sseq is no need to alloc. so separate the check. Signed-off-by: Wang Weidong --- net/tipc/name_table.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index 92a1533..b91387c 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c @@ -159,12 +159,17 @@ static struct sub_seq *tipc_subseq_alloc(u32 cnt) static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_head) { struct name_seq *nseq = kzalloc(sizeof(*nseq), GFP_ATOMIC); - struct sub_seq *sseq = tipc_subseq_alloc(1); + struct sub_seq *sseq; - if (!nseq || !sseq) { + if (!nseq) { pr_warn("Name sequence creation failed, no memory\n"); + return NULL; + } + + sseq = tipc_subseq_alloc(1); + if (!sseq) { + pr_warn("Sub sequence creation failed, no memory\n"); kfree(nseq); - kfree(sseq); return NULL; }