mm/hugetlb: fix error code in hugetlbfs_alloc_inode
Subsystems (2)
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
@@ -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>
Quoted 17 lines · Wanpeng Li
From: Wanpeng Li <[email protected]>
When
kmem_cache_allocfails alloc slab object fromhugetlbfs_inode_cachep, return-ENOMEMin usual. Buthugetlbfs_alloc_inodeimplementation has inconsitency with it and returns NULL. Fix it to return-ENOMEM.Signed-off-by Wanpeng Li <[email protected]>---
fs/hugetlbfs/inode.c| 2 +-1 files changed, 1 insertions(+), 1 deletions(-)fs/hugetlbfs/inode.c +0
-0
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>
Quoted 26 lines · Gavin Shan
Quoted 17 lines · Wanpeng Li
From: Wanpeng Li <[email protected]>
When
kmem_cache_allocfails alloc slab object fromhugetlbfs_inode_cachep, return-ENOMEMin usual. Buthugetlbfs_alloc_inodeimplementation has inconsitency with it and returns NULL. Fix it to return-ENOMEM.Signed-off-by Wanpeng Li <[email protected]>---
fs/hugetlbfs/inode.c| 2 +-1 files changed, 1 insertions(+), 1 deletions(-)fs/hugetlbfs/inode.c +0
-0fs/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,
GavinQuoted 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>
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@@ -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>