From: Heinrich Schuchardt Date: Wed, 23 Sep 2020 19:13:51 +0000 (+0200) Subject: fs/squashfs: parameter check sqfs_read_metablock() X-Git-Tag: v2025.01-rc5-pxa1908~2200^2~2 X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=0ed375ebb13f8b2d69400b9df8985c8123d3fbb1;p=u-boot.git fs/squashfs: parameter check sqfs_read_metablock() We should check if the incoming parameter file_mapping is not NULL instead of checking after adding an offset. Reported-by: Coverity CID 307210 Signed-off-by: Heinrich Schuchardt Acked-by: Thomas Petazzoni --- diff --git a/fs/squashfs/sqfs_inode.c b/fs/squashfs/sqfs_inode.c index 1368f3063c..14d70cf678 100644 --- a/fs/squashfs/sqfs_inode.c +++ b/fs/squashfs/sqfs_inode.c @@ -141,9 +141,9 @@ int sqfs_read_metablock(unsigned char *file_mapping, int offset, const unsigned char *data; u16 header; - data = file_mapping + offset; - if (!data) + if (!file_mapping) return -EFAULT; + data = file_mapping + offset; header = get_unaligned((u16 *)data); if (!header)