2014-05-30 00:28:20

by Trond Myklebust

[permalink] [raw]
Subject: Re: [nfs:testing 48/48] fs/nfs/filelayout/filelayout.c:1351 filelayout_alloc_layout_hdr() error: potential null dereference 'flo'. (kzalloc returns null)

On Fri, 2014-05-30 at 05:56 +0800, kbuild test robot wrote:
> tree: git://git.linux-nfs.org/projects/trondmy/linux-nfs.git testing
> head: a27d2ba9829d092f64076231629ba9bd576facbf
> commit: a27d2ba9829d092f64076231629ba9bd576facbf [48/48] Push the file layout driver into a subdirectory
>
> fs/nfs/filelayout/filelayout.c:1351 filelayout_alloc_layout_hdr() error: potential null dereference 'flo'. (kzalloc returns null)
>
> vim +/flo +1351 fs/nfs/filelayout/filelayout.c
>

Hi Tom,

Looks like your rename unearthed an old skeleton from the closet. I'm
applying the following patch before yours in order to fix it.

Cheers
Trond

8<------------------------------------------------
>From 6df200f5d5191bdde4d2e408215383890f956781 Mon Sep 17 00:00:00 2001
From: Trond Myklebust <[email protected]>
Date: Thu, 29 May 2014 20:06:55 -0400
Subject: [PATCH 1/2] pNFS: Handle allocation errors correctly in
filelayout_alloc_layout_hdr()

Return the NULL pointer when the allocation fails.

Reported-by: Fengguang Wu <[email protected]>
Cc: <[email protected]> # 3.5.x
Signed-off-by: Trond Myklebust <[email protected]>
---
fs/nfs/nfs4filelayout.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index 63a16375660a..21e921147d21 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -1348,7 +1348,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
--
1.9.3


--
Trond Myklebust
Linux NFS client maintainer, PrimaryData
[email protected]