]> err.no Git - linux-2.6/commitdiff
[PATCH] check for failed kmalloc in inftlmount.c
authorGreg Ungerer <gerg@snapgear.com>
Mon, 7 Nov 2005 04:09:50 +0000 (14:09 +1000)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 7 Nov 2005 16:00:46 +0000 (08:00 -0800)
The INFTL mount code contains a kmalloc() followed by a memset() without
handling a possible memory allocation failure.

Signed-off-by: <panagiotis.issaris@mech.kuleuven.ac.be>
Signed-off-by: Greg Ungerer <gerg@uclinux.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/mtd/inftlmount.c

index b5dda47395a71db2f3db02601e9722a73fc98edc..3dac53feeee27561a28b8cc6c35a1bd313ebb17a 100644 (file)
@@ -574,6 +574,12 @@ int INFTL_mount(struct INFTLrecord *s)
 
        /* Temporary buffer to store ANAC numbers. */
        ANACtable = kmalloc(s->nb_blocks * sizeof(u8), GFP_KERNEL);
+       if (!ANACtable) {
+               printk(KERN_WARNING "INFTL: allocation of ANACtable "
+                               "failed (%zd bytes)\n",
+                               s->nb_blocks * sizeof(u8));
+               return -ENOMEM;
+       }
        memset(ANACtable, 0, s->nb_blocks);
 
        /*