Skip to contentSkip to conversation

pch_uart: check kzalloc result in dma_handle_tx()

PATCH New Fengguang Wu 1 participant 1 message Jul 28, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pch_uart: check kzalloc result in dma_handle_tx()

Reported by coccinelle:

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

---
 drivers/tty/serial/pch_uart.c |    4 ++++
 1 file changed, 4 insertions(+)

WARNING: this may be a superficial fix!

drivers/tty/serial/pch_uart.c +4 -0
@@ -974,6 +974,10 @@ static unsigned int dma_handle_tx(struct
 	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;