From patchwork Wed Aug 3 21:42:03 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: 9262249 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 6414260754 for ; Wed, 3 Aug 2016 21:42:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5948227FA9 for ; Wed, 3 Aug 2016 21:42:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DE82280CF; Wed, 3 Aug 2016 21:42:16 +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 A0A3127FA9 for ; Wed, 3 Aug 2016 21:42:15 +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:42:13 +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 u73LgB0D010643; Wed, 3 Aug 2016 17:42:11 -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 u73LgATj234194 for ; Wed, 3 Aug 2016 17:42:10 -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 u73LgASt010637; Wed, 3 Aug 2016 17:42:10 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1AfCAC8ZKJX/yNjr8ZdGwEBAYMngVKlLpF4hAwUhgmBT0wBAQEBAQFehS8ECwFGMAUCJgJgEogxr1yPfgEBAQEGAQEBASOBAYcphyqCZIJaBY8MiiiOfwKPPkiPX1SEGk4BiFkBAQE X-IPAS-Result: A1AfCAC8ZKJX/yNjr8ZdGwEBAYMngVKlLpF4hAwUhgmBT0wBAQEBAQFehS8ECwFGMAUCJgJgEogxr1yPfgEBAQEGAQEBASOBAYcphyqCZIJaBY8MiiiOfwKPPkiPX1SEGk4BiFkBAQE X-IronPort-AV: E=Sophos;i="5.28,467,1464667200"; d="scan'208";a="5622617" 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:42:20 -0400 Received: from fmsmga002-icc.fm.intel.com ([198.175.99.35]) by emsm-gh1-uea11.nsa.gov with ESMTP; 03 Aug 2016 21:42:08 +0000 Received: from fmsmga004-icc.fm.intel.com ([198.175.99.11]) by fmsmga002-icc.fm.intel.com with ESMTP; 03 Aug 2016 14:42:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,467,1464678000"; d="scan'208";a="150201363" Received: from gjdunham-mobl1.amr.corp.intel.com (HELO wcrobert-MOBL1.amr.corp.intel.com) ([10.252.137.217]) by fmsmga004.fm.intel.com with ESMTP; 03 Aug 2016 14:42:06 -0700 From: william.c.roberts@intel.com To: selinux@tycho.nsa.gov, seandroid-list@tycho.nsa.gov, sds@tycho.nsa.gov Subject: [PATCH v2] module_to_cil: fix use of uninitialized variables Date: Wed, 3 Aug 2016 14:42:03 -0700 Message-Id: <1470260523-2511-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;