]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
fs/erofs: Fix realloc error handling
authorFrancois Berder <fberder@outlook.fr>
Tue, 11 Nov 2025 12:49:30 +0000 (13:49 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 5 Dec 2025 22:23:54 +0000 (16:23 -0600)
If realloc failed, raw was not freed and thus memory
was leaked.

Signed-off-by: Francois Berder <fberder@outlook.fr>
fs/erofs/data.c

index 95b609d8ea829b9abf86dc3f001882c7d059541a..b58ec6fcc66696ea0e8eaf7fd51017d807ac6bd2 100644 (file)
@@ -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,