From patchwork Sat Apr 18 08:59:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 237983 List-Id: U-Boot discussion From: bmeng.cn at gmail.com (Bin Meng) Date: Sat, 18 Apr 2020 01:59:11 -0700 Subject: [PATCH 3/3] mkimage: fit: Free buf directly in fit_extract_data() In-Reply-To: <1587200351-12590-1-git-send-email-bmeng.cn@gmail.com> References: <1587200351-12590-1-git-send-email-bmeng.cn@gmail.com> Message-ID: <1587200351-12590-3-git-send-email-bmeng.cn@gmail.com> From: Bin Meng If given ptr to free() is NULL, no operation is performed. Hence we can just free buf directly in fit_extract_data(). Signed-off-by: Bin Meng --- tools/fit_image.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/fit_image.c b/tools/fit_image.c index 05c1f00..965061d 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -527,8 +527,7 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname) err_munmap: munmap(fdt, sbuf.st_size); err: - if (buf) - free(buf); + free(buf); close(fd); return ret; }