Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 56941C433EF for ; Tue, 23 Nov 2021 19:10:15 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A75A882F73; Tue, 23 Nov 2021 20:10:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="lNwc5aJd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1AAC480A4F; Tue, 23 Nov 2021 09:06:44 +0100 (CET) Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 87DC88020E for ; Tue, 23 Nov 2021 09:06:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=hansson.mattias@gmail.com Received: by mail-ed1-x52f.google.com with SMTP id o20so43895600eds.10 for ; Tue, 23 Nov 2021 00:06:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4hq8e1BU3OIEW78JMeOSRHR6WMQBTJvhu+5mWy05L7s=; b=lNwc5aJd+0e1ZVXTijjkyVZ2PZbsliyJFcrGJn595vrq0OD0trZxC5+w9LRAUtxJFP r9u/uI5vZdebXnRJxlHbgTUhYJj75s/doKcEc+YFkxUwlblKf9dOJoMRsHYwHYJnoCBc O79agEHCsfMBtKXLk30qxuPMLrblIzSQr1JcJ8rOmDhoy9nemRgFUZmFDr90aJp/jB9Z X5PQy3uoa8/M8aupKOX5niu6SMlZT4Qy55YM3375Gn1ZbDF1FnVNdZauejSAkcjQ26xs Fn41aCBT/QSX1FeKqC04PAI7j78sVABKnmo+JlIGsUf525Pva26njWM9oS9eeb0bwwt/ We2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4hq8e1BU3OIEW78JMeOSRHR6WMQBTJvhu+5mWy05L7s=; b=MbGVwyPAI9s48c20v5giqxc8V0OW8laiRW244V9gYWA7db7erG3U9Bz2imEACPV5n2 NS7J4YaWTDT2LiQXWID5qwWK2UPGrq8I5qAEfh38y/DTTI0SV9u08tX4bcE9CWtZ66vF Gfz7ar+yHgMXezOzFHrPTvCG1cheR4fY16CpuRNIP3GTJX7U80s3SVYm1ZiO/BGdWtNV mDTv1QEkkfwmkXD6yjas20hxPcBiTkjFy6I62TkYhCRH632L8TRpgBTJac61Hj3m9E04 sV96oYnE+55eiRUuojfjqccwr0YOSfDneKfw8QLWBzVKVzzh0w0gzOk/D8uWAbACIBX8 YvKg== X-Gm-Message-State: AOAM532S/1qBGAnQU1228CqM13V+vB09/yviYxqyDCdsS5LeyXrAtYWt IJF05h24tK+N8aR5ktGHigA1ecTibxk= X-Google-Smtp-Source: ABdhPJxnLE9I3FxckRbL+Ed8ntcoudw+Sr8xkAKIwCIOXWFtnD+5akN4xiM8dy92CqkrPJ+5Ka/G5A== X-Received: by 2002:a17:907:1b1f:: with SMTP id mp31mr5038454ejc.247.1637654799813; Tue, 23 Nov 2021 00:06:39 -0800 (PST) Received: from lemon.ad.global (84-216-106-29.customers.ownit.se. [84.216.106.29]) by smtp.gmail.com with ESMTPSA id x5sm5195570edv.29.2021.11.23.00.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Nov 2021 00:06:39 -0800 (PST) From: Mattias Hansson To: u-boot@lists.denx.de Cc: Mattias Hansson Subject: [PATCH] tools/mxsimage: Remove fclose on empty FILE pointer Date: Tue, 23 Nov 2021 09:06:33 +0100 Message-Id: <20211123080633.8318-1-hansson.mattias@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Tue, 23 Nov 2021 20:10:11 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.37 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean If `sb_load_cmdfile()` fails to open the configuration file it will jump to error handling where the code will try to `fclose()` the FILE pointer which is NULL causing `mkimage` to segfault. This patch removes the `fclose()` since `fopen()` always returns NULL instead of the file descriptor when failing. --- tools/mxsimage.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/mxsimage.c b/tools/mxsimage.c index 002f4b525a..c7bd86ce52 100644 --- a/tools/mxsimage.c +++ b/tools/mxsimage.c @@ -1618,7 +1618,6 @@ static int sb_load_cmdfile(struct sb_image_ctx *ictx) return 0; err_file: - fclose(fp); fprintf(stderr, "ERR: Failed to load file \"%s\"\n", ictx->cfg_filename); return -EINVAL; -- 2.27.0