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: 934b14f2bb ("ext4: free allocations by parse_path()")
Signed-off-by: Mikhail Ilin <ilin.mikhail.ol@gmail.com>
This commit is contained in:
Mikhail Ilin 2022-11-22 11:00:55 +03:00 committed by Tom Rini
parent 2d1b2ac13f
commit 04e6332ec0

View File

@ -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;
}