erofs-utils: mkfs: fix crash when failing to build tree
authorGao Xiang <hsiangkao@linux.alibaba.com>
Thu, 9 Jan 2025 05:05:14 +0000 (13:05 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Thu, 9 Jan 2025 07:43:25 +0000 (15:43 +0800)
For example: It crashes instead of cleanly erroring out if there's
a file for which it doesn't have permissions to read (e.g. /etc/gshadow
has mode 000).

Reported-by: Jonathan Lebon <jonathan@jlebon.com>
Fixes: 6a8e395ae4fd ("erofs-utils: fix up root inode for incremental builds")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20250109050514.3836023-1-hsiangkao@linux.alibaba.com
mkfs/main.c

index 0f6a32bc07ddc7aff6d8b65d51086e5908da7ddd..daea33da407fdf8aaf23bb60ed711bb32759cb98 100644 (file)
@@ -1439,6 +1439,7 @@ int main(int argc, char **argv)
                root = erofs_mkfs_build_tree_from_path(&g_sbi, cfg.c_src_path);
                if (IS_ERR(root)) {
                        err = PTR_ERR(root);
+                       root = NULL;
                        goto exit;
                }
        }