fs/erofs: Fix realloc error handling

If realloc failed, raw was not freed and thus memory
was leaked.

Signed-off-by: Francois Berder <fberder@outlook.fr>
This commit is contained in:
Francois Berder
2025-11-11 13:49:30 +01:00
committed by Tom Rini
parent 00e1fed93c
commit 1c1be32c31

View 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,