From: Amit Choudhary Date: Tue, 8 May 2007 07:26:13 +0000 (-0700) Subject: drivers/char/synclink.c: check kmalloc() return value X-Git-Tag: v2.6.22-rc1~745 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d9a2f4a4945ebff54c9a011e4dc6e92d899ae26d;p=linux-2.6 drivers/char/synclink.c: check kmalloc() return value Signed-off-by: Amit Choudhary Cc: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index ce4db6f523..f02a079598 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c @@ -4010,8 +4010,13 @@ static int mgsl_alloc_intermediate_txbuffer_memory(struct mgsl_struct *info) for ( i=0; inum_tx_holding_buffers; ++i) { info->tx_holding_buffers[i].buffer = kmalloc(info->max_frame_size, GFP_KERNEL); - if ( info->tx_holding_buffers[i].buffer == NULL ) + if (info->tx_holding_buffers[i].buffer == NULL) { + for (--i; i >= 0; i--) { + kfree(info->tx_holding_buffers[i].buffer); + info->tx_holding_buffers[i].buffer = NULL; + } return -ENOMEM; + } } return 0;