Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pNFS: Handle allocation errors correctly in objlayout_alloc_layout_hdr()

Return the NULL pointer when the allocation fails.

Cc: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>

+4 -4
+4 -4
fs/nfs/objlayout/objlayout.c
··· 53 53 struct objlayout *objlay; 54 54 55 55 objlay = kzalloc(sizeof(struct objlayout), gfp_flags); 56 - if (objlay) { 57 - spin_lock_init(&objlay->lock); 58 - INIT_LIST_HEAD(&objlay->err_list); 59 - } 56 + if (!objlay) 57 + return NULL; 58 + spin_lock_init(&objlay->lock); 59 + INIT_LIST_HEAD(&objlay->err_list); 60 60 dprintk("%s: Return %p\n", __func__, objlay); 61 61 return &objlay->pnfs_layout; 62 62 }