This patch series fix several memory leaks, some use of dangling pointers (leading to cpu freeze) and finally introduce the exists() function for squashfs. This function enable testing the existence of a file, which is mandatory for using the distro_bootcmd Those fixes have been cut into several patches to be easier to review
Changes since v1: - patch 5: *dir = *file = NULL; is split in 2 lines - For consistency, sqfs_frag_lookup is modified to use a single "goto out" ( cf https://lists.denx.de/pipermail/u-boot/2020-October/429645.html ) - more memory leak fixes in sqfs_get_abs_path, sqfs_read and sqfs_probe - a missing error check typo in sqfs_get_abs_path - some missing reseting ctxt.sblk to NULL to prevent double free - reset cur_dev/cur_part_info to NULL when they are freed - return value of sqfs_decompressor_init() wasn't used - use "len" in sqfs_read to prevent writing beyond buffer - prevent reading with an offset since it doesn't work - prevent reading fragmented files since it doesn't work Richard Genoud (28): fs/squashfs: fix board hang-up when calling .exists() fs/squashfs: sqfs_opendir: fix some memory leaks and dangling pointers fs/squashfs: sqfs_opendir: simplify error handling fs/squashfs: sqfs_closedir: fix memory leak fs/squashfs: sqfs_split_path: fix memory leak and dangling pointers fs/squashfs: sqfs_read_directory_table: fix memory leak fs/squashfs: sqfs_search_dir: fix dangling pointer fs/squashfs: sqfs_search_dir: fix memory leaks fs/squashfs: sqfs_read_inode_table: fix dangling pointer fs/squashfs: sqfs_concat_tokens: check if malloc succeeds fs/squashfs: sqfs_size: fix dangling pointer dirs->entry fs/squashfs: sqfs_size: remove useless sqfs_closedir() fs/squashfs: sqfs_read: fix dangling pointer dirs->entry fs/squashfs: sqfs_read: remove useless sqfs_closedir() fs/squashfs: sqfs_read: fix memory leak fs/squashfs: sqfs_read: fix another memory leak fs/squashfs: sqfs_frag_lookup: simplify error handling fs/squashfs: sqfs_get_abs_path: fix error check fs/squashfs: sqfs_get_abs_path: fix possible memory leak on error fs/squashfs: sqfs_read: fix memory leak on finfo.blk_sizes fs/squashfs: sqfs_probe: fix possible memory leak on error fs/squashfs: sqfs_close/sqfs_read_sblk: set ctxt.sblk to NULL after free fs/squashfs: sqfs_probe: reset cur_dev/cur_part_info to NULL on error fs/squashfs: sqfs_probe: use sqfs_decompressor_init() return value fs/squashfs: sqfs_read: don't write beyond buffer size fs/squashfs: sqfs_read: remove buggy offset functionality fs/squashfs: sqfs_read: fragmented files are not supported fs/squashfs: implement exists() function fs/fs.c | 7 + fs/squashfs/sqfs.c | 399 +++++++++++++++++++++++++++++++-------------- include/squashfs.h | 1 + 3 files changed, 286 insertions(+), 121 deletions(-)