pNFS: Handle allocation errors correctly in objlayout_alloc_layout_hdr()
Subsystems (2)
PATCH 1/1 pNFS: Handle allocation errors correctly in objlayout_alloc_layout_hdr()
Return the NULL pointer when the allocation fails.
Cc Boaz Harrosh <[email protected]>
Signed-off-by Trond Myklebust <[email protected]>
--- fs/nfs/objlayout/objlayout.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/nfs/objlayout/objlayout.c +4 -4
@@ -53,10 +53,10 @@ objlayout_alloc_layout_hdr(struct inode *inode, gfp_t gfp_flags)struct objlayout *objlay; objlay =kzalloc (sizeof (struct objlayout ), gfp_flags); -if (objlay) { -spin_lock_init (&objlay->lock); -INIT_LIST_HEAD (&objlay->err_list); - } +if (!objlay) +return NULL ; +spin_lock_init (&objlay->lock); +INIT_LIST_HEAD (&objlay->err_list);dprintk ("%s: Return %p\n" , __func__, objlay);return &objlay->pnfs_layout; }
Signature · 1 line
1.9.3
Quoted 18 lines · Trond Myklebust
Return the NULL pointer when the allocation fails.
Cc Boaz Harrosh <[email protected]>Signed-off-by Trond Myklebust <[email protected]>--- fs/nfs/objlayout/objlayout.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)fs/nfs/objlayout/objlayout.c +0
-1@@ -53,10 +53,10 @@ objlayout_alloc_layout_hdr(struct inode *inode, gfp_t gfp_flags)struct objlayout *objlay; objlay =kzalloc (sizeof (struct objlayout ), gfp_flags); -if (objlay) {
fs/nfs/objlayout/objlayout.c objlayout_alloc_layout_hdr(struct inode *inode, gfp_t gfp_flags) · line 62
Quoted 10 lines
fs/nfs/objlayout/objlayout.c +4
-3-spin_lock_init (&objlay->lock); -INIT_LIST_HEAD (&objlay->err_list); - } +if (!objlay) +return NULL ; +spin_lock_init (&objlay->lock); +INIT_LIST_HEAD (&objlay->err_list);dprintk ("%s: Return %p\n" , __func__, objlay);return &objlay->pnfs_layout; }
Thanks! ACK
BTW it was not a bug. &NULL->pnfs_layout will return 0 because it is at offset 0. Which explains why it works.
Thanks again, good catch
Boaz