[PATCH] staging: dgnc: check return value of kzalloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



check return value of kzalloc and return error if it fails.

Signed-off-by: Gujulan Elango Hari Prasath <hgujulan@xxxxxxxxxxx>
---
 drivers/staging/dgnc/dgnc_tty.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index ce4187f..2397c66 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -316,6 +316,8 @@ int dgnc_tty_init(struct dgnc_board *brd)
 			 * interrupt context, and there are no locks held.
 			 */
 			brd->channels[i] = kzalloc(sizeof(*brd->channels[i]), GFP_KERNEL);
+			if (!brd->channels[i])
+				return -ENOMEM;
 		}
 	}
 
@@ -1126,10 +1128,16 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file)
 
 	if (!ch->ch_rqueue)
 		ch->ch_rqueue = kzalloc(RQUEUESIZE, GFP_KERNEL);
+		if (!ch->ch_rqueue)
+			return -ENOMEM;
 	if (!ch->ch_equeue)
 		ch->ch_equeue = kzalloc(EQUEUESIZE, GFP_KERNEL);
+		if (!ch->ch_equeue)
+			return -ENOMEM;
 	if (!ch->ch_wqueue)
 		ch->ch_wqueue = kzalloc(WQUEUESIZE, GFP_KERNEL);
+		if (!ch->ch_wqueue)
+			return -ENOMEM;
 
 	spin_lock_irqsave(&ch->ch_lock, flags);
 
-- 
1.9.1
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux