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

Signed-off-by: Gujulan Elango Hari Prasath <hguju...@visteon.com>
---
 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
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to