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:
committed by
Tom Rini
parent
00e1fed93c
commit
1c1be32c31
+5
-2
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user