From patchwork Thu Oct 12 15:03:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 824909 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:400c:c09::23e; helo=mail-wm0-x23e.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbvmi73hakgqevqhy33y@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="XS3v/+xm"; dkim-atps=neutral Received: from mail-wm0-x23e.google.com (mail-wm0-x23e.google.com [IPv6:2a00:1450:400c:c09::23e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yCYyc507Lz9t32 for ; Fri, 13 Oct 2017 02:03:52 +1100 (AEDT) Received: by mail-wm0-x23e.google.com with SMTP id y142sf3284527wme.12 for ; Thu, 12 Oct 2017 08:03:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1507820629; cv=pass; d=google.com; s=arc-20160816; b=OBKX5I+hRNE/ZAl533TSRvbDrDWRMK/Nqy7CZMVI3dyX9OJlk79PfrbkDZuRD8QjNL /mqjqTlKOBh4pRliI1iORmoM6d71za1/9yUigKbggY4JzRt5kJrlzQbkD+OnAFA+JSaE nx45+lTPwdYjNw0ZMS7g8bgWSadP3V+YXzX8no2OYjBB04Zys8U6gsPaY7CCKwlStjVd HNl22zRvmBEIfd1x9J/301Fwop7p/mjE0WubUMKXT0VJJUXH9npdRlrDVtNWxSlcyIjU Lx5KmUn+CobK0wJcqJqU+XM0YTAMBbUt/jDERx9zLcqKAX9VmBm98T+c5APXf/8doKCo AX7w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:message-id:date:subject:cc:to:from :arc-authentication-results:arc-message-signature:mime-version :sender:dkim-signature:arc-authentication-results; bh=eWqEauT4BEPOAKDKsFm9pJ5L7UDdrq+ifsGRJxbBZvw=; b=CAoQgFvmbStrjvs8JVazO/KFVFqC5cFBKZV0Z8ydJ4us0o4o0QPULPXa44Vkx/5mLI RSgspyMYE1FgKY49vMRn2MQsKW6cW5Dv6Okzs6f9JnkiMxhW9eGMv9nPvc/xa1Nd2a2I dQ2uXgV0qQX9upr2NYnyXzdDpNfYcNu86AucDN5qynHrFTKs8JjEZR0JcLua3H8y0UYq wLx5KQLMv61T7Tq89YSQW/n0lR/AhaJhh2AEccBhi+qopemBTX5vhR6HO/i3kyeAgoaw h509xpG7temmBWxChzJWv5yDfYxD/fdI3LnIK5yza1l8KDiHc823WfJHz0o7HsYUs3p8 OEDg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 192.35.17.2 is neither permitted nor denied by domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=eWqEauT4BEPOAKDKsFm9pJ5L7UDdrq+ifsGRJxbBZvw=; b=XS3v/+xmVXcg6RGFqN4bgb/nPebuPHEU44eEOjRLfXmU/VVXaERS6tTEZa+xQsHWGJ ZIP29snWQu6iZsyn0MpNGCEElDLjCGXyP0zS5J+zMR06N78RfpjScDaITyTBviVjYwEX PtvKHWf/sz4DhES5XCQWJsCe6vbcLRSpavZEgSPaGSZti8KnWU6yu4WvCWZSQGJm+eI7 Lqw46lhvRwsbocc26mfIfWUKpp0OLqo9+oW0MFmBmnwZzknWK2buseAaULxLoBZsfR7G Z6GquFWhEJv23oRsYeqRFbAU/w6DlQK5fkbpdxJ6D6CSadni6x3cd3WzHOYyinqk1NfT m9QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=eWqEauT4BEPOAKDKsFm9pJ5L7UDdrq+ifsGRJxbBZvw=; b=Uts/5vyqZUYBJZCsvPEN97C76SZLYcGImRfL9NB/9obqNvowS9fqu0KtXkd64Ltdmw GqrHkHUGgXyGDrmYiqDmM22DCtZshc44nNwxTMelxp/50p1v7AeAvAulu4U1PHir6sWC oOAIOwyzCvlJvorMYfzkwaSwhmYz4cIkse6BMPz2n8XjUtzypgr/CJpnPXlwtCw1rLRm I0j4HICDhc0DLM5qbtbJZtQgLMvabUm7PdNAtkKKGAjzbLXSb5yU1sRosCM48yMZJep0 48QD95PFepXbLmHblf9koSTfrt6qInM/USql04sg8+DMOBxCeDres/qllYd7DEALJuqN 95aw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AMCzsaU5QkhV8dvvMOqvHJuzNDMHz9Nfc6DUEVC7lvW/aH7jraq0EIve mxenuM9usMKNtEqvSFjBCng= X-Google-Smtp-Source: AOwi7QDC3BORR1BM1iR/BAmDgvDnaZoJ9nw6+ov+uDa1dhhUn6H+MrRRci5SyAPf2kNwzDvl6oNuKg== X-Received: by 10.28.147.143 with SMTP id v137mr22971wmd.5.1507820629711; Thu, 12 Oct 2017 08:03:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.80.189.203 with SMTP id z11ls2015135edh.1.gmail; Thu, 12 Oct 2017 08:03:49 -0700 (PDT) X-Received: by 10.80.152.61 with SMTP id g58mr822129edb.5.1507820629272; Thu, 12 Oct 2017 08:03:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507820629; cv=none; d=google.com; s=arc-20160816; b=XgnCc1kkQfVtIjcKCOaCOpHhJUoiFMnpo6Fj4I7E40o/ZhX5pxr5TcowUD8D969uTu iadSAdU6inaX3jQDdsrZL32kGaw5qelVIotQtFun1dN3cdkfiA17XB38YR35S1xWEhyy sIkJfRO46ozdTt6V/ItC9ubF+Lj4gEtmZIgVb9GMAgfw2G9Hy85vJsR7B/23qZlEEOrg OLK0sAMeP97JwEi2PGPpUlcFohfbyAvVJBsMnvVHgW1hbeA2Ad/ujHWU7CKS8nBhd9ld ofXvN4bKogHV+8w4likkzvUaF8UuBMeOdtOVqQWysSR6s8A9rmucZ42H8wZGwFRgDnke DTRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=wdhokVbozPO1+Xvm0liemXI1BxV/YdlwFUD9sRoQ8mo=; b=dICAp/5lKKJt4rpiWv1v8ooBlrUHwvzmP/AJcf6Hxeffng1Qw1Ye04pNv5ECoWgAP8 vukNIzENQ4IcwN8JUA1h0JHnZn7hknBuEq2zg1ddpRYlH0jThadbj9hBi1VlEQ7eNzWe xLdbE02LF4FVAGY68G6fUW45yd7zmCLWO5hvf9rOfvFt7lG17z9fmbNdAJoAvxsm8E0L j26OSII8+1jGDvECd91pnPl0WGz92qI2ZiPTKsHGq0vncStuIAfe+Tz4p+pa/0CrAAKE EltTR4mlPiJdoKVJrKpNzjPOiZMUr4m9mb3zn6qYA49K0/dk6lOBksb5Gtc8y9I/SvlR 97yQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 192.35.17.2 is neither permitted nor denied by domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id h23si221197ede.4.2017.10.12.08.03.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Oct 2017 08:03:49 -0700 (PDT) Received-SPF: neutral (google.com: 192.35.17.2 is neither permitted nor denied by domain of christian.storm@siemens.com) client-ip=192.35.17.2; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id v9CF3mOI010223 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 12 Oct 2017 17:03:48 +0200 Received: from MD1KR9XC.ww002.siemens.net ([139.25.69.251]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id v9CF3mYB013570; Thu, 12 Oct 2017 17:03:48 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH] Lua: don't double-close Lua state on missing hook Date: Thu, 12 Oct 2017 17:03:33 +0200 Message-Id: <20171012150333.22913-1-christian.storm@siemens.com> X-Mailer: git-send-email 2.14.2 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 192.35.17.2 is neither permitted nor denied by domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , If the Lua hook function cannot be found, then lua_parser_fn() closes the Lua state. Thereafter, parser() in parser/parser.c closes the Lua state again via lua_parser_exit(), resulting in a segmentation fault: software = { version = "0.0.1"; images: ( { filename = "dummy.root"; device = "/dev/mmcblk0p3"; hook = "segfault"; } ); embedded-script = ""; } Hence, don't close the Lua stack in lua_parser_fn() but instead clean up the stack removing the nil pushed to it via lua_getglobal(). Signed-off-by: Christian Storm Acked-by: Stefano Babic --- corelib/lua_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index 39ed01f..8698a1d 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -550,7 +550,7 @@ int lua_parser_fn(lua_State *L, const char *fcn, struct img_type *img) lua_getglobal(L, fcn); if(!lua_isfunction(L, lua_gettop(L))) { - lua_close(L); + lua_pop(L, 1); TRACE("Script : no %s in script, exiting", fcn); return -1; }