]> git.hungrycats.org Git - linux/commitdiff
libnvdimm, btt: check memory allocation failure
authorChristophe Jaillet <christophe.jaillet@wanadoo.fr>
Sun, 27 Aug 2017 06:30:34 +0000 (08:30 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Sep 2017 06:27:48 +0000 (08:27 +0200)
commit ed36b4dba54a421ce5551638f6a9790b2c2116b1 upstream.

Check memory allocation failures and return -ENOMEM in such cases, as
already done few lines below for another memory allocation.

This avoids NULL pointers dereference.

Fixes: 14e494542636 ("libnvdimm, btt: BTT updates for UEFI 2.7 format")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nvdimm/btt.c

index 14323faf8bd96fbeacc6a55dc6733553a53e1c68..7ec6393b6ba1299468a0c3b833da5a5ec598d95e 100644 (file)
@@ -1429,6 +1429,8 @@ int nvdimm_namespace_attach_btt(struct nd_namespace_common *ndns)
        }
 
        btt_sb = devm_kzalloc(&nd_btt->dev, sizeof(*btt_sb), GFP_KERNEL);
+       if (!btt_sb)
+               return -ENOMEM;
 
        /*
         * If this returns < 0, that is ok as it just means there wasn't