Skip to contentSkip to conversation

f2fs: alloc_page() doesn't return an ERR_PTR

PATCH Superseded Dan Carpenter 2 participants 4 messages Aug 14, 2013 – Aug 15, 2013

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

PATCH 1/1 f2fs: alloc_page() doesn't return an ERR_PTR

alloc_page() returns a NULL on failure, it never returns an ERR_PTR.

fs/f2fs/node.c +2 -2
index f5172e2..3e87fe0 100644
@@ -1515,8 +1515,8 @@ int restore_node_summary(struct f2fs_sb_info *sbi,
 
 	/* alloc temporal page for read node */
 	page = alloc_page(GFP_NOFS | __GFP_ZERO);
-	if (IS_ERR(page))
-		return PTR_ERR(page);
+	if (!page)
+		return -ENOMEM;
 	lock_page(page);
 
 	/* scan the node segment */
#1 lore raw

Hi Dan,

Agreed.
Could you make a patch that covers other alloc_page cases too?

# grep alloc_page fs/f2fs/*
fs/f2fs/node.c:	page = alloc_page(GFP_NOFS | __GFP_ZERO);
fs/f2fs/recovery.c: page = alloc_page(GFP_F2FS_ZERO);
fs/f2fs/recovery.c: page = alloc_page(GFP_NOFS | __GFP_ZERO);

Thank you,

2013-08-14 (수), 14:41 +0300, Dan Carpenter:

Quoted 19 lines

alloc_page() returns a NULL on failure, it never returns an ERR_PTR.

fs/f2fs/node.c +2 -2
index f5172e2..3e87fe0 100644
@@ -1515,8 +1515,8 @@ int restore_node_summary(struct f2fs_sb_info *sbi,
 
 	/* alloc temporal page for read node */
 	page = alloc_page(GFP_NOFS | __GFP_ZERO);
-	if (IS_ERR(page))
-		return PTR_ERR(page);
+	if (!page)
+		return -ENOMEM;
 	lock_page(page);
 
 	/* scan the node segment */
Signature · 7 lines
Jaegeuk Kim
Samsung

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
Quoted 4 lines · Jaegeuk Kim

Hi Dan,

Agreed.
Could you make a patch that covers other alloc_page cases too?

Sure. Thanks for catching that. I will resend a v2 of this one which fixes those as well.

regards,
dan carpenter

#3 lore raw

PATCH v2 1/1 f2fs: alloc_page() doesn't return an ERR_PTR

In reply to Jaegeuk Kim

alloc_page() returns a NULL on failure, it never returns an ERR_PTR.

---
v2: fix the calls in recovery.c as well.

fs/f2fs/node.c +2 -2
index f5172e2..3e87fe0 100644
@@ -1515,8 +1515,8 @@ int restore_node_summary(struct f2fs_sb_info *sbi,
 
 	/* alloc temporal page for read node */
 	page = alloc_page(GFP_NOFS | __GFP_ZERO);
-	if (IS_ERR(page))
-		return PTR_ERR(page);
+	if (!page)
+		return -ENOMEM;
 	lock_page(page);
 
 	/* scan the node segment */
fs/f2fs/recovery.c +3 -3
index 639eb34..889b4bd 100644
@@ -129,8 +129,8 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)
 
 	/* read node page */
 	page = alloc_page(GFP_F2FS_ZERO);
-	if (IS_ERR(page))
-		return PTR_ERR(page);
+	if (!page)
+		return -ENOMEM;
 	lock_page(page);
 
 	while (1) {
@@ -367,7 +367,7 @@ static int recover_data(struct f2fs_sb_info *sbi,
 
 	/* read node page */
 	page = alloc_page(GFP_NOFS | __GFP_ZERO);
-	if (IS_ERR(page))
+	if (!page)
 		return -ENOMEM;
 
 	lock_page(page);