From patchwork Fri Nov 19 15:44:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattias Hansson X-Patchwork-Id: 1557417 X-Patchwork-Delegate: sbabic@denx.de 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; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=AJJGVB98; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HwpH266pwz9sRN for ; Sat, 20 Nov 2021 07:31:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F32EB80607; Fri, 19 Nov 2021 21:31:37 +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="AJJGVB98"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2CC9082FCA; Fri, 19 Nov 2021 16:44:13 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) (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 E7A2E80C8F for ; Fri, 19 Nov 2021 16:44:09 +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-x52b.google.com with SMTP id z5so44461564edd.3 for ; Fri, 19 Nov 2021 07:44:09 -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=AJJGVB98iNd5zNhV+v9eICHKMVKEZgbk6iRVI1TuOkvAHxOz9VRJGhIzvmFhV4a1AC J6LX/yi8DaA8RTN5zIaBeZxKeyuJMPw5GCbWqcUsyKSRRihVIbJaf79Ty2ZRc7vfYpFb q9FVZECKuevfW7C6mJDkFN9OYmEy+Oh2J6+K3AIDihw7Oyh5rDk4LwVbCbAQVDKy0/Wx iJanptI7TvTvwPrMD25c1S4yjhnMiGgFFFFxPsfVSY+MuqcmlSvMUFBDH/MFtR4Ryas6 1n/0ZcYBiYEHN7NG0Vath2wma616KZATKqA0hjbtCeO33t7EhboVa3eVNtK7fpTD8Roj O+ug== 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=Nmkd7C5MuTduJuotXGnvcOt002SZYfHrrwb0JEHaIqb0g9hT8zpgzRPp9GLfhtPHRb JD4QSHx4WDx8SZ/SkcnQUv5X2ubxinDSUmDbZwVpLVmrHW7CWlIykFFHhYPzFL9KjM8r wtRp9tW+aQquzmKP0C9GBEWE3B1BTOfS1IhlRGMVEFQHq7q5xH2tqfJz1ip9uBeuUXMF co2WcrljhE31nSyuajJiacmTkfkEoPjB1rYizB+WTScIBPCYuqOR72G94tV1qMRl0cmS ny74ruRrHW8OxaQJNZoiKzjHOCfEdDng54q+/i19NJPA37EOtiT0yP3teWr9IyvTiQdw ZXSA== X-Gm-Message-State: AOAM53352t3CIz7v+gfcihzfJsHXiBsqWCIxRSKR1iIaPD9b44+y1Q4N z7JY7F+PzB1fVyi+/4wYKgwRDZWfPro= X-Google-Smtp-Source: ABdhPJzDg0cvg4Qhws6GqR8mMPWx5Q7WCYXuyjPq4QlwyAETOd3icpXyBkTgg3fY+Ts9NptD7h1cVQ== X-Received: by 2002:a50:c3c8:: with SMTP id i8mr26319795edf.317.1637336649247; Fri, 19 Nov 2021 07:44:09 -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 sg17sm89638ejc.72.2021.11.19.07.44.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 07:44:08 -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: Fri, 19 Nov 2021 16:44:04 +0100 Message-Id: <20211119154404.24665-1-hansson.mattias@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 19 Nov 2021 21:31:36 +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;