U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: ant.v.moryakov@gmail.com
To: ant.v.moryakov@gmail.com, u-boot@lists.denx.de
Cc: Maks Mishin <maks.mishinFZ@gmail.com>
Subject: [PATCH] tools: Fix handle leak in mmap_fdt function
Date: Fri, 18 Apr 2025 11:15:23 +0300	[thread overview]
Message-ID: <20250418081526.11327-2-ant.v.moryakov@gmail.com> (raw)
In-Reply-To: <20250418081526.11327-1-ant.v.moryakov@gmail.com>

From: Maks Mishin <maks.mishinFZ@gmail.com>

The handle 'ptr' is created at fit_common.c:91 by calling 
function 'mmap' and lost at fit_common.c:127: 
Added call of free for `ptr` if ptr != MAP_FAILED.

Trigger was found by the Svace static analyzer.

Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
---
 tools/fit_common.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/fit_common.c b/tools/fit_common.c
index d1cde16c1c..135e105929 100644
--- a/tools/fit_common.c
+++ b/tools/fit_common.c
@@ -123,6 +123,7 @@ err:
 		close(fd);
 	if (delete_on_error)
 		unlink(fname);
+	free(ptr);
 
 	return -1;
 }
-- 
2.34.1

       reply	other threads:[~2025-04-18  8:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20250418081526.11327-1-ant.v.moryakov@gmail.com>
2025-04-18  8:15 ` ant.v.moryakov [this message]
2025-04-18 11:24   ` [PATCH] tools: Fix handle leak in mmap_fdt function Yao Zi
2025-02-09 14:56 Maks Mishin
2025-02-18 19:45 ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250418081526.11327-2-ant.v.moryakov@gmail.com \
    --to=ant.v.moryakov@gmail.com \
    --cc=maks.mishinFZ@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox