From: Alec Brown <alec.r.brown@oracle.com>
To: grub-devel@gnu.org
Cc: daniel.kiper@oracle.com, darren.kenny@oracle.com
Subject: [PATCH] affs: Fix resource leaks
Date: Wed, 2 Feb 2022 19:08:21 -0500 [thread overview]
Message-ID: <1643846901-7889-1-git-send-email-alec.r.brown@oracle.com> (raw)
In commit 178ac5107389 (affs: Fix memory leaks), fixes were made to
grub_affs_iterate_dir() to prevent memory leaks from occuring after it returns
without freeing node. However, there were still some instances where node was
causing a memory leak when the function returns after calling
grub_affs_create_node(). In this function, new memory is allocated to node but
doesn't get freed until the hook() function is called near the end. Before
hook() is called, node should be freed in grub_affs_create_node() before
returning out of it.
Fixes: 178ac5107389 (affs: Fix memory leaks)
Fixes: CID 73759
Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
---
grub-core/fs/affs.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/grub-core/fs/affs.c b/grub-core/fs/affs.c
index cafcd0fba..7b9e62064 100644
--- a/grub-core/fs/affs.c
+++ b/grub-core/fs/affs.c
@@ -370,17 +370,26 @@ grub_affs_create_node (grub_fshelp_node_t dir,
GRUB_DISK_SECTOR_SIZE - GRUB_AFFS_FILE_LOCATION,
sizeof ((*node)->di), (char *) &(*node)->di);
if (err)
- return 1;
+ {
+ grub_free (*node);
+ return 1;
+ }
continue;
}
default:
- return 0;
+ {
+ grub_free (*node);
+ return 0;
+ }
}
break;
}
if (nest == 8)
- return 0;
+ {
+ grub_free (*node);
+ return 0;
+ }
type |= GRUB_FSHELP_CASE_INSENSITIVE;
--
2.27.0
next reply other threads:[~2022-02-03 0:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-03 0:08 Alec Brown [this message]
2022-02-03 11:58 ` [PATCH] affs: Fix resource leaks Darren Kenny
2022-02-04 14:34 ` Daniel Kiper
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=1643846901-7889-1-git-send-email-alec.r.brown@oracle.com \
--to=alec.r.brown@oracle.com \
--cc=daniel.kiper@oracle.com \
--cc=darren.kenny@oracle.com \
--cc=grub-devel@gnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.