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

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

 



From: Hari Prasath Gujulan Elango <hgujulan@xxxxxxxxxxx>

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

Signed-off-by: Hari Prasath Gujulan Elango <hgujulan@xxxxxxxxxxx>
---
	v2:Deleted multiple empty lines as checkpatch.pl with strict
	option warned about it as per review comments from sudip
---
 drivers/staging/dgnc/dgnc_driver.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index 7546aff..0ed16db 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -384,13 +384,13 @@ 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