pNFS: Handle allocation errors correctly in filelayout_alloc_layout_hdr()
authorTrond Myklebust <trond.myklebust@primarydata.com>
Fri, 30 May 2014 00:06:55 +0000 (20:06 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 7 Jul 2014 01:54:14 +0000 (18:54 -0700)
commit 6df200f5d5191bdde4d2e408215383890f956781 upstream.

Return the NULL pointer when the allocation fails.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/nfs/nfs4filelayout.c

index 22d10623f5ee3b591de10631044cf90cef4d353a..b039f7f26d95c00b9c28bc908ab5976338c1157a 100644 (file)
@@ -1300,7 +1300,7 @@ filelayout_alloc_layout_hdr(struct inode *inode, gfp_t gfp_flags)
        struct nfs4_filelayout *flo;
 
        flo = kzalloc(sizeof(*flo), gfp_flags);
-       return &flo->generic_hdr;
+       return flo != NULL ? &flo->generic_hdr : NULL;
 }
 
 static void