Skip to contentSkip to conversation

mm/hugetlb: fix error code in hugetlbfs_alloc_inode

PATCH Superseded Wanpeng Li 3 participants 4 messages Jul 10, 2012

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wanpeng Li

author
#0 lore raw

PATCH 1/1 mm/hugetlb: fix error code in hugetlbfs_alloc_inode

From: Wanpeng Li <[email protected]>

When kmem_cache_alloc fails alloc slab object from hugetlbfs_inode_cachep, return -ENOMEM in usual. But hugetlbfs_alloc_inode implementation has inconsitency with it and returns NULL. Fix it to return -ENOMEM.

---
 fs/hugetlbfs/inode.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/hugetlbfs/inode.c +1 -1
index c4b85d0..79a0f33 100644
@@ -696,7 +696,7 @@ static struct inode *hugetlbfs_alloc_inode(struct super_block *sb)
 	p = kmem_cache_alloc(hugetlbfs_inode_cachep, GFP_KERNEL);
 	if (unlikely(!p)) {
 		hugetlbfs_inc_free_inodes(sbinfo);
-		return NULL;
+		return -ENOMEM;
 	}
 	return &p->vfs_inode;
 }
Signature · 7 lines
1.7.5.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 17 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

When kmem_cache_alloc fails alloc slab object from hugetlbfs_inode_cachep, return -ENOMEM in usual. But hugetlbfs_alloc_inode implementation has inconsitency with it and returns NULL. Fix it to return -ENOMEM.

---
fs/hugetlbfs/inode.c | 2 +-

1 files changed, 1 insertions(+), 1 deletions(-)
fs/hugetlbfs/inode.c +0 -0
index c4b85d0..79a0f33 100644

fs/hugetlbfs/inode.c static struct inode *hugetlbfs_alloc_inode(struct super_block *sb) · line 699

Quoted 5 lines
fs/hugetlbfs/inode.c +1 -1
@@ -696,7 +696,7 @@ static struct inode *hugetlbfs_alloc_inode(struct super_block *sb)
 	p = kmem_cache_alloc(hugetlbfs_inode_cachep, GFP_KERNEL);
 	if (unlikely(!p)) {
 		hugetlbfs_inc_free_inodes(sbinfo);
-		return NULL;
+		return -ENOMEM;

The function is expecting "struct inode *", man.

static struct inode *hugetlbfs_alloc_inode(struct super_block *sb)

Thanks,
Gavin

Quoted 12 lines
fs/hugetlbfs/inode.c +0 -0
 	}
 	return &p->vfs_inode;
 }
Signature · 7 lines
1.7.5.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#2 lore raw
Quoted 26 lines · Gavin Shan
Quoted 17 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

When kmem_cache_alloc fails alloc slab object from hugetlbfs_inode_cachep, return -ENOMEM in usual. But hugetlbfs_alloc_inode implementation has inconsitency with it and returns NULL. Fix it to return -ENOMEM.

---
fs/hugetlbfs/inode.c | 2 +-

1 files changed, 1 insertions(+), 1 deletions(-)
fs/hugetlbfs/inode.c +0 -0
index c4b85d0..79a0f33 100644

fs/hugetlbfs/inode.c static struct inode *hugetlbfs_alloc_inode(struct super_block *sb) · line 699

Quoted 5 lines
fs/hugetlbfs/inode.c +1 -1
@@ -696,7 +696,7 @@ static struct inode *hugetlbfs_alloc_inode(struct super_block *sb)
 	p = kmem_cache_alloc(hugetlbfs_inode_cachep, GFP_KERNEL);
 	if (unlikely(!p)) {
 		hugetlbfs_inc_free_inodes(sbinfo);
-		return NULL;
+		return -ENOMEM;

The function is expecting "struct inode *", man.

Quoted 2 lines

static struct inode *hugetlbfs_alloc_inode(struct super_block *sb)

Hmm, replace it by ERR_PTR(-ENOMEM).

Regards,
Wanpeng Li

Quoted 15 lines

Thanks,
Gavin

Quoted 12 lines
fs/hugetlbfs/inode.c +0 -0
 	}
 	return &p->vfs_inode;
 }
Signature · 7 lines
1.7.5.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw
Quoted 13 lines · Wanpeng Li
Quoted 13 lines

fs/hugetlbfs/inode.c static struct inode *hugetlbfs_alloc_inode(struct super_block *sb) · line 699

Quoted 10 lines
fs/hugetlbfs/inode.c +1 -1
index c4b85d0..79a0f33 100644
@@ -696,7 +696,7 @@ static struct inode *hugetlbfs_alloc_inode(struct super_block *sb)
 	p = kmem_cache_alloc(hugetlbfs_inode_cachep, GFP_KERNEL);
 	if (unlikely(!p)) {
 		hugetlbfs_inc_free_inodes(sbinfo);
-		return NULL;
+		return -ENOMEM;

The function is expecting "struct inode *", man.

Quoted 4 lines
Quoted 2 lines

static struct inode *hugetlbfs_alloc_inode(struct super_block *sb)

Hmm, replace it by ERR_PTR(-ENOMEM).

Please listen to the feedback you're getting before you reply.

This function is called by alloc_inode(). It tests whether the return value is NULL or not, it doesn't check for PTR_ERR(). It's correct the way it's written and you would have broken it.

In the future, please demonstrate how you've tested your patches before proposing them.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>