mirror of
https://xff.cz/git/u-boot/
synced 2025-09-29 22:41:17 +02:00
fs: fat: memory leak in fat_unlink()
Do not leak filename_copy in case of error. Catch out of memory when calling strdup. Reported-by: Coverity (CID: 184086) Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
committed by
Tom Rini
parent
46580f2fd5
commit
0d532e911c
@@ -1259,6 +1259,11 @@ int fat_unlink(const char *filename)
|
|||||||
char *filename_copy, *dirname, *basename;
|
char *filename_copy, *dirname, *basename;
|
||||||
|
|
||||||
filename_copy = strdup(filename);
|
filename_copy = strdup(filename);
|
||||||
|
if (!filename_copy) {
|
||||||
|
printf("Error: allocating memory\n");
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
split_filename(filename_copy, &dirname, &basename);
|
split_filename(filename_copy, &dirname, &basename);
|
||||||
|
|
||||||
if (!strcmp(dirname, "/") && !strcmp(basename, "")) {
|
if (!strcmp(dirname, "/") && !strcmp(basename, "")) {
|
||||||
@@ -1270,7 +1275,8 @@ int fat_unlink(const char *filename)
|
|||||||
itr = malloc_cache_aligned(sizeof(fat_itr));
|
itr = malloc_cache_aligned(sizeof(fat_itr));
|
||||||
if (!itr) {
|
if (!itr) {
|
||||||
printf("Error: allocating memory\n");
|
printf("Error: allocating memory\n");
|
||||||
return -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = fat_itr_root(itr, &fsdata);
|
ret = fat_itr_root(itr, &fsdata);
|
||||||
|
Reference in New Issue
Block a user