From patchwork Mon Jul 18 02:24:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 1657275 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=gGqeF1V8; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=TauCykIE; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LmQt90vctz9sFs for ; Mon, 18 Jul 2022 12:30:25 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=TLGN4gz21DVCo5+S+4FDsVvQmP8a5pWyUd1mDVLVefo=; b=gGqeF1V8WSgCTo DtknHIGnbgPmdGRaLji9rd9XiT4STFb/7x1CyAKGxF2xwW3IfSBpyPCDEkpkNU4YtSE6c6JrYTR3s g731sy8zry6kCJV1uVz8pTeBDizV0wTJyta1hl2iZSN+ZLgksElaLXvQf8TNlEpcS7OXG6/xcJlIJ R4kjbxZ4nF/YzZwQosCK2wOQ6V2fqfbRffzJcYyUM18R4bGKhd3kqEZVZE5Nv+nHNuNZ6TpfaGpp8 njpY6xkAIMeSEp5xKlq4znlA10I6OLgc0ZmYDuKlBMHn8P05/z/2CxY7ySgtEu5/TI7CKfedylB9l kw9Mwr5y+WD5NSDdQz3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDGRI-00A7Ks-3I; Mon, 18 Jul 2022 02:24:52 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDGRB-00A7Ip-3H for openwrt-devel@lists.openwrt.org; Mon, 18 Jul 2022 02:24:46 +0000 Received: by mail-pf1-x42a.google.com with SMTP id g126so9474655pfb.3 for ; Sun, 17 Jul 2022 19:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=91zIm9R+WjsV4nu05oWrx8wZLAOhJE+T9OqEWXcX2l4=; b=TauCykIEG6/8ik/QwKhhOwaPqtdwb5/vLRVK6vRU+lggqlERBa763a212Zxb6R9VGJ 8/TcWLM7TGeFuK0kPq+4gNiI+1sNrlzFCL9Tm+js1Et9t9VuAgVSEFjTtXh+dYQrtOPg u4fhgZmqISzoTsonAJilBQc/90GY4XuD7z+5zpu7Dn5/c//Naw7qKaBg2RymqwnOb9Zo 8J1QFAKkOcmnFrPT0+JKjqi8QOVBFsycx0wqkerbWVG39r+WvlqXxkcUQMqydwKwom4Y 9FufTZjsgEpEyJsbWWkWEEHiaUaih/pIKJ6JO7qmq67wx64STdvwEsrXgvdw64gnR1ko HI8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=91zIm9R+WjsV4nu05oWrx8wZLAOhJE+T9OqEWXcX2l4=; b=G01e7Rsfznxa7oCbvGoDl1OpmrdXKyKfTNDBlk80RRnhwDRZqGmAJR3dUbxUnH749p y3nut39SrwRZqf22rYfEeJxN3Yc3snhROhhEQNp2IzBp303O+44kD7YNZH/LX8C3GSYh s68v0W947RVjKQpRqzh101mLlCMuYtlMAU79kOoQw/+rBFbzxoWjWe7o6cogDVryKO7F EWFu/z6QgHuO/2fqmhjItHqAFst6QhQKbyvdm3n3i4BcMZgcHGQXG09DjLjACGL6oKhH lckhbwIfXmyKXDuWjOpUNRzb+47FrJxIzpuvM+8nduEEm/3MREE2BYsaL0Nnqdnu08Qq kOHg== X-Gm-Message-State: AJIora/496Po4zySVE4VmxAypE+wW0+fSOHSfPRMvjbyoFC9FgaFgjiF jEDPFD+9gN55Dk+aP5TRk1X+Fr649Yk= X-Google-Smtp-Source: AGRyM1s1SxkOMB2vSmslSpFqXQJgBqeQDlms4qvBpIAJ2Aerzc58vERXqjrL7nh3qBBAi0DtQze/ZA== X-Received: by 2002:a63:65c2:0:b0:419:8146:b1a7 with SMTP id z185-20020a6365c2000000b004198146b1a7mr23304084pgb.210.1658111079935; Sun, 17 Jul 2022 19:24:39 -0700 (PDT) Received: from ryzen.lan ([2601:648:8600:b53::8c6]) by smtp.gmail.com with ESMTPSA id j12-20020a170903024c00b0016c4546fbf9sm8067519plh.128.2022.07.17.19.24.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jul 2022 19:24:39 -0700 (PDT) From: Rosen Penev To: openwrt-devel@lists.openwrt.org Subject: [PATCH 1/2] ubox: fix GCC fanalyzer warnings Date: Sun, 17 Jul 2022 19:24:36 -0700 Message-Id: <20220718022437.1714176-1-rosenp@gmail.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220717_192445_160670_1DC3A681 X-CRM114-Status: GOOD ( 10.59 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: memory leaks and missing NULL checks. Signed-off-by: Rosen Penev --- kmodloader.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/kmodloader.c b/kmodloader.c index 63bae5e..bc5f20c 100644 --- a/kmodloader.c +++ b/kmodloader.c @@ -336,6 +336,11 @@ static int scan_loaded_modules(void) /* possibly a module outside /lib [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [rosenp[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:42a listed in] [list.dnswl.org] X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org memory leaks and missing NULL checks. Signed-off-by: Rosen Penev --- kmodloader.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/kmodloader.c b/kmodloader.c index 63bae5e..bc5f20c 100644 --- a/kmodloader.c +++ b/kmodloader.c @@ -336,6 +336,11 @@ static int scan_loaded_modules(void) /* possibly a module outside /lib/modules// */ n = alloc_module(m.name, NULL, 0, m.depends, m.size); } + if (!n) { + ULOG_ERR("Failed to allocate memory for module\n"); + return -1; + } + n->usage = m.usage; n->state = LOADED; } @@ -416,7 +421,8 @@ out: if (fd >= 0) close(fd); - free(aliases); + if (aliases) + free(aliases); return m; } @@ -581,6 +587,11 @@ static int insert_module(char *path, const char *options) struct stat s; int fd, ret = -1; + if (!path) { + ULOG_ERR("Path not specified\n"); + return ret; + } + if (stat(path, &s)) { ULOG_ERR("missing module %s\n", path); return ret; @@ -1162,6 +1173,8 @@ load_options(void) continue; } } + + fclose(f); } int main(int argc, char **argv)