This patch removes the error statements that follow
kzalloc. These are useless because kzalloc has its
own error statement and the driver's error handling
would never actually happen.

Reported-by: Dan Carpenter <dan.carpen...@oracle.com>
Signed-off-by: Lidza Louina <lidza.lou...@gmail.com>
---
 drivers/staging/dgnc/dgnc_driver.c | 10 ----------
 drivers/staging/dgnc/dgnc_tty.c    | 18 +-----------------
 2 files changed, 1 insertion(+), 27 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 4d90ba3..15896b0 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -500,20 +500,10 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
        /* get the board structure and prep it */
        brd = dgnc_Board[dgnc_NumBoards] =
        kzalloc(sizeof(brd), GFP_KERNEL);
-       if (!brd) {
-               APR(("memory allocation for board structure failed\n"));
-               return(-ENOMEM);
-       }
 
        /* make a temporary message buffer for the boot messages */
        brd->msgbuf = brd->msgbuf_head =
                kzalloc(sizeof(char) * 8192, GFP_KERNEL);
-       if (!brd->msgbuf) {
-               kfree(brd);
-               APR(("memory allocation for board msgbuf failed\n"));
-               return(-ENOMEM);
-       }
-
        /* store the info for the board we've found */
        brd->magic = DGNC_BOARD_MAGIC;
        brd->boardnum = dgnc_NumBoards;
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 8880df2..b03e373 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -231,8 +231,6 @@ int dgnc_tty_register(struct dgnc_board *brd)
         * tty_struct's and termios's.
         */
        brd->SerialDriver.ttys = kzalloc(brd->maxports * 
sizeof(brd->SerialDriver.ttys), GFP_KERNEL);
-       if (!brd->SerialDriver.ttys)
-               return(-ENOMEM);
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
        brd->SerialDriver.refcount = brd->TtyRefCnt;
@@ -241,13 +239,10 @@ int dgnc_tty_register(struct dgnc_board *brd)
 #endif
 
        brd->SerialDriver.termios = kzalloc(brd->maxports * 
sizeof(brd->SerialDriver.termios), GFP_KERNEL);
-       if (!brd->SerialDriver.termios)
-               return(-ENOMEM);
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
        brd->SerialDriver.termios_locked = kzalloc(brd->maxports * 
sizeof(brd->SerialDriver.termios_locked), GFP_KERNEL);
-       if (!brd->SerialDriver.termios_locked)
-               return(-ENOMEM);
+
 #endif
        /*
         * Entry points for driver.  Called by the kernel from
@@ -290,8 +285,6 @@ int dgnc_tty_register(struct dgnc_board *brd)
         * the Serial Driver so we don't get confused
         */
        brd->PrintDriver.ttys = kzalloc(brd->maxports * 
sizeof(brd->PrintDriver.ttys), GFP_KERNEL);
-       if (!brd->PrintDriver.ttys)
-               return(-ENOMEM);
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
        brd->PrintDriver.refcount = brd->TtyRefCnt;
@@ -300,13 +293,8 @@ int dgnc_tty_register(struct dgnc_board *brd)
 #endif
 
        brd->PrintDriver.termios = kzalloc(brd->maxports * 
sizeof(brd->PrintDriver.termios), GFP_KERNEL);
-       if (!brd->PrintDriver.termios)
-               return(-ENOMEM);
-
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
        brd->PrintDriver.termios_locked = kzalloc(brd->maxports * 
sizeof(brd->PrintDriver.termios_locked), GFP_KERNEL);
-       if (!brd->PrintDriver.termios_locked)
-               return(-ENOMEM);
 #endif
 
        /*
@@ -372,10 +360,6 @@ 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]) {
-                               DPR_CORE(("%s:%d Unable to allocate memory for 
channel struct\n",
-                                   __FILE__, __LINE__));
-                       }
                }
        }
 
-- 
1.8.1.2

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to