diff options
author | Mikhail Ilin <ilin.mikhail.ol@gmail.com> | 2022-11-22 11:00:55 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-12-08 09:28:31 -0500 |
commit | 04e6332ec0b139a0b7452551455ae96428c7d1ef (patch) | |
tree | 99cd69b9375cfe7bc35a06ed23c83102b8ff603d /fs | |
parent | 2d1b2ac13fe5be6aa149e7a8ab5b059f0ad05476 (diff) | |
download | u-boot-04e6332ec0b139a0b7452551455ae96428c7d1ef.tar.gz u-boot-04e6332ec0b139a0b7452551455ae96428c7d1ef.tar.bz2 u-boot-04e6332ec0b139a0b7452551455ae96428c7d1ef.zip |
fs: ext4: Fix free(NULL)
The 'depth_dirname', 'ptr', 'parent_inode' and 'first_inode' pointers
may be null. Thus, it is necessary to check them before using free() to
avoid free(NULL) cases.
Fixes: 934b14f2bb30 ("ext4: free allocations by parse_path()")
Signed-off-by: Mikhail Ilin <ilin.mikhail.ol@gmail.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/ext4_common.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c index 1185cb2c04..f50de7c089 100644 --- a/fs/ext4/ext4_common.c +++ b/fs/ext4/ext4_common.c @@ -850,15 +850,20 @@ end: fail: free(depth_dirname); - free(parse_dirname); - for (i = 0; i < depth; i++) { - if (!ptr[i]) - break; - free(ptr[i]); + if (parse_dirname) + free(parse_dirname); + if (ptr) { + for (i = 0; i < depth; i++) { + if (!ptr[i]) + break; + free(ptr[i]); + } + free(ptr); } - free(ptr); - free(parent_inode); - free(first_inode); + if (parent_inode) + free(parent_inode); + if (first_inode) + free(first_inode); return result_inode_no; } |