Skip to contentSkip to conversation

erofs: fix return value check in erofs_read_superblock()

PATCH In review Wei Yongjun 3 participants 3 messages Sep 18, 2019 – Sep 19, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 erofs: fix return value check in erofs_read_superblock()

In case of error, the function read_mapping_page() returns ERR_PTR() not NULL. The NULL test in the return value check should be replaced with IS_ERR().

Fixes fe7c2423570d ("erofs: use read_mapping_page instead of sb_bread")
---
 fs/erofs/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/erofs/super.c +2 -2
index caf9a95173b0..0e369494f2f2 100644
@@ -105,9 +105,9 @@ static int erofs_read_superblock(struct super_block *sb)
 	int ret;
 
 	page = read_mapping_page(sb->s_bdev->bd_inode->i_mapping, 0, NULL);
-	if (!page) {
+	if (IS_ERR(page)) {
 		erofs_err(sb, "cannot read erofs superblock");
-		return -EIO;
+		return PTR_ERR(page);
 	}
 
 	sbi = EROFS_SB(sb);
Reviewed-by on v1 1/1
#1 lore raw

Hi Yongjun,

Quoted 6 lines · Wei Yongjun

In case of error, the function read_mapping_page() returns ERR_PTR() not NULL. The NULL test in the return value check should be replaced with IS_ERR().

Fixes fe7c2423570d ("erofs: use read_mapping_page instead of sb_bread")

Right... That is my mistake on recent killing bh transformation...

I have no idea this patch could be merged for -rc1 since I don't know Greg could still accept patches or freezed...

Since it's an error handling path and trivial, if it's some late, could I submit this later after erofs is merged into mainline (if it's ok) for -rc1? (or maybe -rc2?)

Thanks,
Gao Xiang

Quoted 23 lines
---
 fs/erofs/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/erofs/super.c +2 -2
index caf9a95173b0..0e369494f2f2 100644
@@ -105,9 +105,9 @@ static int erofs_read_superblock(struct super_block *sb)
 	int ret;
 
 	page = read_mapping_page(sb->s_bdev->bd_inode->i_mapping, 0, NULL);
-	if (!page) {
+	if (IS_ERR(page)) {
 		erofs_err(sb, "cannot read erofs superblock");
-		return -EIO;
+		return PTR_ERR(page);
 	}
 
 	sbi = EROFS_SB(sb);