From: Francois Berder Date: Tue, 11 Nov 2025 12:49:30 +0000 (+0100) Subject: fs/erofs: Fix realloc error handling X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c1be32c31cbec61d32f7aaa498ccc25567ae3e0;p=thirdparty%2Fu-boot.git fs/erofs: Fix realloc error handling If realloc failed, raw was not freed and thus memory was leaked. Signed-off-by: Francois Berder --- diff --git a/fs/erofs/data.c b/fs/erofs/data.c index 95b609d8ea8..b58ec6fcc66 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -319,12 +319,15 @@ static int z_erofs_read_data(struct erofs_inode *inode, char *buffer, } if (map.m_plen > bufsize) { + char *tmp; + bufsize = map.m_plen; - raw = realloc(raw, bufsize); - if (!raw) { + tmp = realloc(raw, bufsize); + if (!tmp) { ret = -ENOMEM; break; } + raw = tmp; } ret = z_erofs_read_one_data(inode, &map, raw,