From patchwork Tue Nov 5 00:36:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1189257 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fTDdtoUp"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 476W5G2WVZz9sNT for ; Tue, 5 Nov 2019 11:39:30 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=F45AM+gDPAUKSQTIecmY4WNVifs8rEFnX+um8wLErWM=; b=fTDdtoUpkYug1D B8xJR1Em8bcdJGwudoP0oSisjmmWNpLLZWUjPJQlt355unL42fu4BlJAy/IlKPS6WXeCQdugVYWIj m7TQMYRrYQML1w4sW3NVnRAq2bsTGWgC15w8wiynQ4Fodp3OEH7Of5m3vS6IH1B87JALyZjLjzbcL vQrXPDqKS9DQEVM+zniHBqKN/hQGVow8yWuLiwxYGTHrDf2wmf3F+xilY6gWxPD4xFYrQdlShd51T jupgxkBp69DDOsYnHW9YvV3RBWzCoQWHAjXf5a4YuAY4FcID3BWZBUxt7nMqXRlKU6LJfmAUW3Z0E +IF9Ii1aLwz3xoS2SNiQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iRmsX-0002Rt-QZ; Tue, 05 Nov 2019 00:39:25 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iRmqS-0008Al-2T for openwrt-devel@lists.openwrt.org; Tue, 05 Nov 2019 00:37:18 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 2CD024D8D; Tue, 5 Nov 2019 01:37:14 +0100 (CET) Received: by meh.true.cz (OpenSMTPD) with ESMTP id b479ceba; Tue, 5 Nov 2019 01:37:04 +0100 (CET) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Date: Tue, 5 Nov 2019 01:36:56 +0100 Message-Id: <20191105003657.16540-18-ynezz@true.cz> In-Reply-To: <20191105003657.16540-1-ynezz@true.cz> References: <20191105003657.16540-1-ynezz@true.cz> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191104_163716_278785_322353FC X-CRM114-Status: UNSURE ( 8.59 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.217.244.18 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record Subject: [OpenWrt-Devel] [PATCH uci 17/18] ucimap: fix possible use of memory after it is freed X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Petr_=C5=A0tetiar?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org scan-build from clang version 9 has reported following issue: ucimap.c:710:8: warning: Use of memory after it is freed err = ucimap_parse_options(map, sm, sd, s); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Petr Štetiar --- ucimap.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ucimap.c b/ucimap.c index d5fd5c4f7143..7c2b0435d308 100644 --- a/ucimap.c +++ b/ucimap.c @@ -490,16 +490,21 @@ ucimap_add_section_list(struct uci_map *map, struct ucimap_section_data *sd) map->sdata_tail = &sd->next; } -static void +static int ucimap_add_section(struct ucimap_section_data *sd) { + int r; struct uci_map *map = sd->map; sd->next = NULL; - if (sd->sm->add(map, ucimap_section_ptr(sd)) < 0) + r = sd->sm->add(map, ucimap_section_ptr(sd)); + if (r < 0) { ucimap_free_section(map, sd); - else + return r; + } else ucimap_add_section_list(map, sd); + + return 0; } #ifdef UCI_DEBUG @@ -702,7 +707,9 @@ ucimap_parse_section(struct uci_map *map, struct uci_sectionmap *sm, struct ucim goto error; if (map->parsed) { - ucimap_add_section(sd); + err = ucimap_add_section(sd); + if (err) + return err; } else { ucimap_add_section_list(map, sd); }