소스 검색

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 <xypron.glpk@gmx.de>
Acked-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Heinrich Schuchardt 3 년 전
부모
커밋
0ed375ebb1
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      fs/squashfs/sqfs_inode.c

+ 2 - 2
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)