[PATCH] staging: dgnc: check return value before using pointer

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

 



Check the return value of kcalloc first and then use the pointer.

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

diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index 805dc61..935e297 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -385,13 +385,14 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
 	/* make a temporary message buffer for the boot messages */
 	brd->msgbuf_head = kcalloc(8192, sizeof(u8), GFP_KERNEL);
-	brd->msgbuf = brd->msgbuf_head;
-
-	if (!brd->msgbuf) {
+	if (!brd->msgbuf_head) {
 		kfree(brd);
 		return -ENOMEM;
 	}
 
+	brd->msgbuf = brd->msgbuf_head;
+
+
 	/* store the info for the board we've found */
 	brd->magic = DGNC_BOARD_MAGIC;
 	brd->boardnum = dgnc_NumBoards;
-- 
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