pch_uart: check kzalloc result in dma_handle_tx()
authorFengguang Wu <fengguang.wu@intel.com>
Sat, 28 Jul 2012 12:43:57 +0000 (20:43 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 Aug 2012 19:10:16 +0000 (12:10 -0700)
Reported by coccinelle:

drivers/tty/serial/pch_uart.c:979:1-14: alloc with no test, possible model on line 994

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/pch_uart.c

index 558ce85..4cd6c23 100644 (file)
@@ -979,6 +979,10 @@ static unsigned int dma_handle_tx(struct eg20t_port *priv)
        priv->tx_dma_use = 1;
 
        priv->sg_tx_p = kzalloc(sizeof(struct scatterlist)*num, GFP_ATOMIC);
+       if (!priv->sg_tx_p) {
+               dev_err(priv->port.dev, "%s:kzalloc Failed\n", __func__);
+               return 0;
+       }
 
        sg_init_table(priv->sg_tx_p, num); /* Initialize SG table */
        sg = priv->sg_tx_p;