From: Greg Ungerer Date: Mon, 7 Nov 2005 04:09:50 +0000 (+1000) Subject: [PATCH] check for failed kmalloc in inftlmount.c X-Git-Tag: v2.6.15-rc1~465 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8766af935f3f018ec4fd420644360643838ec323;p=linux-2.6 [PATCH] check for failed kmalloc in inftlmount.c The INFTL mount code contains a kmalloc() followed by a memset() without handling a possible memory allocation failure. Signed-off-by: Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds --- diff --git a/drivers/mtd/inftlmount.c b/drivers/mtd/inftlmount.c index b5dda47395..3dac53feee 100644 --- a/drivers/mtd/inftlmount.c +++ b/drivers/mtd/inftlmount.c @@ -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); /*