U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scripts: Fix potential null-deref
@ 2025-04-18  8:19 ant.v.moryakov
  2025-04-18  8:19 ` [PATCH] tools: Fix memory and descriptor leak ant.v.moryakov
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: ant.v.moryakov @ 2025-04-18  8:19 UTC (permalink / raw)
  To: u-boot; +Cc: Maks Mishin

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

Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
---
 scripts/kconfig/menu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 5c5c1374..a0d0d2af 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -812,8 +812,10 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym,
 			}
 		}
 	}
-	for_all_prompts(sym, prop)
-		get_prompt_str(r, prop, head);
+	if (sym) {
+		for_all_prompts(sym, prop)
+			get_prompt_str(r, prop, head);
+	}
 
 	prop = get_symbol_prop(sym);
 	if (prop) {
-- 
2.34.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [PATCH] tools: Fix memory and descriptor leak
@ 2025-04-18 18:21 ant.v.moryakov
  0 siblings, 0 replies; 10+ messages in thread
From: ant.v.moryakov @ 2025-04-18 18:21 UTC (permalink / raw)
  To: u-boot; +Cc: Maks Mishin, Anton Moryakov

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

Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
---
 tools/zynqmpbif.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/tools/zynqmpbif.c b/tools/zynqmpbif.c
index 82ce0ac1a52..33c68eac9f3 100644
--- a/tools/zynqmpbif.c
+++ b/tools/zynqmpbif.c
@@ -205,7 +205,7 @@ static const struct bif_flags bif_flags[] = {
 
 static char *read_full_file(const char *filename, size_t *size)
 {
-	char *buf, *bufp;
+	char *buf = NULL, *bufp;
 	struct stat sbuf;
 	int len = 0, r, fd;
 
@@ -214,24 +214,28 @@ static char *read_full_file(const char *filename, size_t *size)
 		return NULL;
 
 	if (fstat(fd, &sbuf) < 0)
-		return NULL;
+		goto out;
 
 	if (size)
 		*size = sbuf.st_size;
 
 	buf = malloc(sbuf.st_size);
 	if (!buf)
-		return NULL;
+		goto out;
 
 	bufp = buf;
 	while (len < sbuf.st_size) {
 		r = read(fd, bufp, sbuf.st_size - len);
-		if (r < 0)
-			return NULL;
+		if (r < 0) {
+			free(buf);
+			buf = NULL;
+			goto out;
+		}
 		len += r;
 		bufp += r;
 	}
 
+out:
 	close(fd);
 
 	return buf;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-04-18 18:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-18  8:19 [PATCH] scripts: Fix potential null-deref ant.v.moryakov
2025-04-18  8:19 ` [PATCH] tools: Fix memory and descriptor leak ant.v.moryakov
2025-04-18 13:51   ` Quentin Schulz
2025-04-18  8:19 ` [PATCH] tools: Fix potential memory leak in aisimage.c ant.v.moryakov
2025-04-18 13:52   ` Quentin Schulz
2025-04-18  8:19 ` [PATCH] tools: image-host: Fix potential memory leak ant.v.moryakov
2025-04-18 13:52   ` Quentin Schulz
2025-04-18 13:51 ` [PATCH] scripts: Fix potential null-deref Quentin Schulz
2025-04-18 14:18   ` Tom Rini
  -- strict thread matches above, loose matches on Subject: below --
2025-04-18 18:21 [PATCH] tools: Fix memory and descriptor leak ant.v.moryakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox