summaryrefslogtreecommitdiff
path: root/fs/fat
diff options
context:
space:
mode:
authorAndrew F. Davis <afd@ti.com>2019-05-16 09:34:31 -0500
committerTom Rini <trini@konsulko.com>2019-05-28 13:57:52 -0400
commitd0cd30eb8137c0f14034aeb22c9f00cd70ccc98c (patch)
tree578f8d0eb912a6adc8b64b92640c60853c384738 /fs/fat
parent7b437807ee0a051f46d329e868e0295299026b75 (diff)
fs: fat: Fix possible double free of fatbuf
fat_itr_root() allocates fatbuf so we free it on the exit path, if the function fails we should not free it, check the return value and skip freeing if the function fails. Signed-off-by: Andrew F. Davis <afd@ti.com>
Diffstat (limited to 'fs/fat')
-rw-r--r--fs/fat/fat.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index c5997c2173..06c8ed14bd 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -1134,11 +1134,12 @@ int fat_size(const char *filename, loff_t *size)
* expected to fail if passed a directory path:
*/
free(fsdata.fatbuf);
- fat_itr_root(itr, &fsdata);
- if (!fat_itr_resolve(itr, filename, TYPE_DIR)) {
+ ret = fat_itr_root(itr, &fsdata);
+ if (ret)
+ goto out_free_itr;
+ ret = fat_itr_resolve(itr, filename, TYPE_DIR);
+ if (!ret)
*size = 0;
- ret = 0;
- }
goto out_free_both;
}