From: Amit Choudhary Date: Tue, 8 May 2007 07:26:13 +0000 (-0700) Subject: drivers/char/synclink.c: check kmalloc() return value X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=d9a2f4a4945ebff54c9a011e4dc6e92d899ae26d;p=openwrt%2Fstaging%2Fblogic.git 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 ce4db6f52362..f02a0795983f 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;