From patchwork Wed Aug 3 21:37:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Roberts, William C" X-Patchwork-Id: 9262247 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0910460754 for ; Wed, 3 Aug 2016 21:38:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1177208C2 for ; Wed, 3 Aug 2016 21:38:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5009280CF; Wed, 3 Aug 2016 21:38:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from emsm-gh1-uea11.nsa.gov (emsm-gh1-uea11.nsa.gov [8.44.101.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4B147208C2 for ; Wed, 3 Aug 2016 21:38:39 +0000 (UTC) Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea11.nsa.gov with ESMTP; 03 Aug 2016 21:38:37 +0000 Received: from prometheus.infosec.tycho.ncsc.mil (prometheus [192.168.25.40]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u73Lborn009891; Wed, 3 Aug 2016 17:37:58 -0400 Received: from tarius.tycho.ncsc.mil (tarius.infosec.tycho.ncsc.mil [144.51.242.1]) by prometheus.infosec.tycho.ncsc.mil (8.15.2/8.15.2) with ESMTP id u73LbBe0234174 for ; Wed, 3 Aug 2016 17:37:11 -0400 Received: from goalie.tycho.ncsc.mil (goalie [144.51.242.250]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u73LbBVi009852; Wed, 3 Aug 2016 17:37:11 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1AfCABbY6JX/yNjr8ZdGwEBAYMngVKlLZF4hAwUhgmBT0wBAQEBAQFehS8ECwFGMAUCJgJgEogxr1uPfgEBAQEGAQEBASOBAYcphyqCZIJaBY8MiiiOf48+AkiPX1SEGhwyAYhZAQEB X-IPAS-Result: A1AfCABbY6JX/yNjr8ZdGwEBAYMngVKlLZF4hAwUhgmBT0wBAQEBAQFehS8ECwFGMAUCJgJgEogxr1uPfgEBAQEGAQEBASOBAYcphyqCZIJaBY8MiiiOf48+AkiPX1SEGhwyAYhZAQEB X-IronPort-AV: E=Sophos;i="5.28,467,1464667200"; d="scan'208";a="5622606" Received: from emsm-gh1-uea11.corp.nsa.gov (HELO emsm-gh1-uea11.nsa.gov) ([10.208.41.37]) by goalie.tycho.ncsc.mil with ESMTP; 03 Aug 2016 17:37:21 -0400 Received: from fmsmga002-icc.fm.intel.com ([198.175.99.35]) by emsm-gh1-uea11.nsa.gov with ESMTP; 03 Aug 2016 21:37:09 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga002-icc.fm.intel.com with ESMTP; 03 Aug 2016 14:37:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.28,467,1464678000"; d="scan'208"; a="1029274628" Received: from gjdunham-mobl1.amr.corp.intel.com (HELO wcrobert-MOBL1.amr.corp.intel.com) ([10.252.137.217]) by orsmga002.jf.intel.com with ESMTP; 03 Aug 2016 14:37:06 -0700 From: william.c.roberts@intel.com To: selinux@tycho.nsa.gov, seandroid-list@tycho.nsa.gov, sds@tycho.nsa.gov Subject: [PATCH] module_to_cil: fix possible use of initialized value Date: Wed, 3 Aug 2016 14:37:04 -0700 Message-Id: <1470260224-761-1-git-send-email-william.c.roberts@intel.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-BeenThere: selinux@tycho.nsa.gov X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-Virus-Scanned: ClamAV using ClamSMTP From: William Roberts Correct errors like these reported by gcc: module_to_cil.c: In function ‘block_to_cil’: module_to_cil.c:229:20: error: ‘attr_list’ may be used uninitialized in this function [-Werror=maybe-uninitialized] struct list_node *curr = (*attr_list)->head; Usages of attr_list_destroy() were called when list_init() fails. Just bail early on failure. stack_init() and stack_destroy() also suffered from the aforementioned issue. Signed-off-by: William Roberts --- libsepol/src/module_to_cil.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libsepol/src/module_to_cil.c b/libsepol/src/module_to_cil.c index b9a4af7..9d0d064 100644 --- a/libsepol/src/module_to_cil.c +++ b/libsepol/src/module_to_cil.c @@ -1307,7 +1307,7 @@ static int cond_list_to_cil(int indent, struct policydb *pdb, struct cond_node * rc = list_init(&attr_list); if (rc != 0) { - goto exit; + return rc; } for (cond = cond_list; cond != NULL; cond = cond->next) { @@ -3488,7 +3488,7 @@ static int block_to_cil(struct policydb *pdb, struct avrule_block *block, struct rc = list_init(&attr_list); if (rc != 0) { - goto exit; + return rc; } rc = typealiases_to_cil(indent, pdb, block, stack); @@ -3635,7 +3635,7 @@ static int blocks_to_cil(struct policydb *pdb) rc = stack_init(&stack); if (rc != 0) { - goto exit; + return rc; } block = pdb->global; @@ -3703,7 +3703,7 @@ static int linked_blocks_to_cil(struct policydb *pdb) rc = stack_init(&stack); if (rc != 0) { - goto exit; + return rc; } block = pdb->global;