]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fs/squashfs: parameter check sqfs_read_metablock()
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Wed, 23 Sep 2020 19:13:51 +0000 (21:13 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 29 Sep 2020 17:19:08 +0000 (13:19 -0400)
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 <xypron.glpk@gmx.de>
Acked-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
fs/squashfs/sqfs_inode.c

index 1368f3063c5cd019577181270e283b57ddba9fc9..14d70cf6789d9f6974f4c1a12dd62f0d2157a70e 100644 (file)
@@ -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)