[PATCH 4.13 16/43] ovl: add NULL check in ovl_alloc_inode

From: Greg Kroah-Hartman
Date: Tue Oct 31 2017 - 05:58:02 EST


4.13-stable review patch. If anyone has any objections, please let me know.

------------------

From: Hirofumi Nakagawa <nklabs@xxxxxxxxx>

commit b3885bd6edb41b91a0e3976469f72ae31bfb8d95 upstream.

This was detected by fault injection test

Signed-off-by: Hirofumi Nakagawa <nklabs@xxxxxxxxx>
Fixes: 13cf199d0088 ("ovl: allocate an ovl_inode struct")
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
fs/overlayfs/super.c | 3 +++
1 file changed, 3 insertions(+)

--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -174,6 +174,9 @@ static struct inode *ovl_alloc_inode(str
{
struct ovl_inode *oi = kmem_cache_alloc(ovl_inode_cachep, GFP_KERNEL);

+ if (!oi)
+ return NULL;
+
oi->cache = NULL;
oi->redirect = NULL;
oi->version = 0;