]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] kfree cleanup: drivers/char
authorJesper Juhl <jesper.juhl@gmail.com>
Mon, 7 Nov 2005 09:01:29 +0000 (01:01 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 7 Nov 2005 15:54:02 +0000 (07:54 -0800)
This is the drivers/char/ part of the big kfree cleanup patch.

Remove pointless checks for NULL prior to calling kfree() in drivers/char/.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
13 files changed:
drivers/char/consolemap.c
drivers/char/drm/ffb_context.c
drivers/char/drm/ffb_drv.c
drivers/char/ip2/i2ellis.c
drivers/char/istallion.c
drivers/char/n_hdlc.c
drivers/char/pcmcia/synclink_cs.c
drivers/char/rocket.c
drivers/char/selection.c
drivers/char/stallion.c
drivers/char/synclink.c
drivers/char/synclinkmp.c
drivers/char/tty_io.c

index 406dea914635f166a529ddb7529bb01f805f19ce..c85a4fa60da7e235b207a6ba84d305928ec1e142 100644 (file)
@@ -345,17 +345,15 @@ static void con_release_unimap(struct uni_pagedir *p)
        for (i = 0; i < 32; i++) {
                if ((p1 = p->uni_pgdir[i]) != NULL) {
                        for (j = 0; j < 32; j++)
-                               if (p1[j])
-                                       kfree(p1[j]);
+                               kfree(p1[j]);
                        kfree(p1);
                }
                p->uni_pgdir[i] = NULL;
        }
-       for (i = 0; i < 4; i++)
-               if (p->inverse_translations[i]) {
-                       kfree(p->inverse_translations[i]);
-                       p->inverse_translations[i] = NULL;
-               }
+       for (i = 0; i < 4; i++) {
+               kfree(p->inverse_translations[i]);
+               p->inverse_translations[i] = NULL;
+       }
 }
 
 void con_free_unimap(struct vc_data *vc)
index 8a6cc2751bc9253a2f2b779177972081e0c23cfe..1383727b443ad98fb28795b1f71c7ecd02ff0d46 100644 (file)
@@ -526,10 +526,8 @@ int ffb_driver_rmctx(struct inode *inode, struct file *filp, unsigned int cmd,
        if (idx < 0 || idx >= FFB_MAX_CTXS)
                return -EINVAL;
 
-       if (fpriv->hw_state[idx] != NULL) {
-               kfree(fpriv->hw_state[idx]);
-               fpriv->hw_state[idx] = NULL;
-       }
+       kfree(fpriv->hw_state[idx]);
+       fpriv->hw_state[idx] = NULL;
        return 0;
 }
 
index 5c121d6df9f2d4139d4ae76a7451bd6e826da216..c13f9abb41e9b2f3ad88a8303e525ebf874b35d5 100644 (file)
@@ -245,14 +245,12 @@ static void ffb_driver_release(drm_device_t * dev, struct file *filp)
 
 static void ffb_driver_pretakedown(drm_device_t * dev)
 {
-       if (dev->dev_private)
-               kfree(dev->dev_private);
+       kfree(dev->dev_private);
 }
 
 static int ffb_driver_postcleanup(drm_device_t * dev)
 {
-       if (ffb_position != NULL)
-               kfree(ffb_position);
+       kfree(ffb_position);
        return 0;
 }
 
index f834d05ccc976bb90828047c29fd1af28350e7fa..dd761a1e4f084709bd1e5c3dfac6ccbab5878826 100644 (file)
@@ -106,9 +106,7 @@ iiEllisInit(void)
 static void
 iiEllisCleanup(void)
 {
-       if ( pDelayTimer != NULL ) {
-               kfree ( pDelayTimer );
-       }
+       kfree(pDelayTimer);
 }
 
 //******************************************************************************
index e3ddbdb85a2f3d4d6addf22ddc360cfbafa57299..ce3bc0d45f1f0c8fb2794257e5971078688045ac 100644 (file)
@@ -860,10 +860,9 @@ static void __exit istallion_module_exit(void)
        if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem")))
                printk("STALLION: failed to un-register serial memory device, "
                        "errno=%d\n", -i);
-       if (stli_tmpwritebuf != (char *) NULL)
-               kfree(stli_tmpwritebuf);
-       if (stli_txcookbuf != (char *) NULL)
-               kfree(stli_txcookbuf);
+
+       kfree(stli_tmpwritebuf);
+       kfree(stli_txcookbuf);
 
        for (i = 0; (i < stli_nrbrds); i++) {
                if ((brdp = stli_brds[i]) == (stlibrd_t *) NULL)
index 5079beda69b5af142af8e9bfaa4ffd62c635c881..c3660d8781a4ef35e6fce62532d2629bfa4039ab 100644 (file)
@@ -264,8 +264,7 @@ static void n_hdlc_release(struct n_hdlc *n_hdlc)
                } else
                        break;
        }
-       if (n_hdlc->tbuf)
-               kfree(n_hdlc->tbuf);
+       kfree(n_hdlc->tbuf);
        kfree(n_hdlc);
        
 }      /* end of n_hdlc_release() */
index 02d7f046c10aeae25e831b2f15f9f85e63a22d99..2c326ea53421be1797e4405e20a69926a51c8e78 100644 (file)
@@ -2994,8 +2994,7 @@ int rx_alloc_buffers(MGSLPC_INFO *info)
 
 void rx_free_buffers(MGSLPC_INFO *info)
 {
-       if (info->rx_buf)
-               kfree(info->rx_buf);
+       kfree(info->rx_buf);
        info->rx_buf = NULL;
 }
 
index 928b850cc679839707c47e44d3e13ab4a06ac09e..d3bc731fbb2773cbe6c94c92505781cb63a0bb50 100644 (file)
@@ -2512,10 +2512,8 @@ static void rp_cleanup_module(void)
                       "rocketport driver\n", -retval);
        put_tty_driver(rocket_driver);
 
-       for (i = 0; i < MAX_RP_PORTS; i++) {
-               if (rp_table[i])
-                       kfree(rp_table[i]);
-       }
+       for (i = 0; i < MAX_RP_PORTS; i++)
+               kfree(rp_table[i]);
 
        for (i = 0; i < NUM_BOARDS; i++) {
                if (rcktpt_io_addr[i] <= 0 || is_PCI[i])
index 16d630f58bb491cbf5394960ef5a8e90f30f4b4f..5b187c895c1831fc1bf274aeaa6e7fe35f0c8244 100644 (file)
@@ -246,8 +246,7 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t
                clear_selection();
                return -ENOMEM;
        }
-       if (sel_buffer)
-               kfree(sel_buffer);
+       kfree(sel_buffer);
        sel_buffer = bp;
 
        obp = bp;
index 1c686414e0a1f6dfc2b5d40e9584666302bc951a..95af2a941595517ca0ea30daa4a380a739724475 100644 (file)
@@ -785,8 +785,7 @@ static void __exit stallion_module_exit(void)
                        "errno=%d\n", -i);
        class_destroy(stallion_class);
 
-       if (stl_tmpwritebuf != (char *) NULL)
-               kfree(stl_tmpwritebuf);
+       kfree(stl_tmpwritebuf);
 
        for (i = 0; (i < stl_nrbrds); i++) {
                if ((brdp = stl_brds[i]) == (stlbrd_t *) NULL)
@@ -804,8 +803,7 @@ static void __exit stallion_module_exit(void)
                                        continue;
                                if (portp->tty != (struct tty_struct *) NULL)
                                        stl_hangup(portp->tty);
-                               if (portp->tx.buf != (char *) NULL)
-                                       kfree(portp->tx.buf);
+                               kfree(portp->tx.buf);
                                kfree(portp);
                        }
                        kfree(panelp);
index 0133dc0e25d087cfd4cabedb261d28f0572fdd98..5d1ffa3bd4c3e0bd7d9a39e1cfc68ebbfb7c515c 100644 (file)
@@ -4016,9 +4016,7 @@ static int mgsl_alloc_intermediate_rxbuffer_memory(struct mgsl_struct *info)
  */
 static void mgsl_free_intermediate_rxbuffer_memory(struct mgsl_struct *info)
 {
-       if ( info->intermediate_rxbuffer )
-               kfree(info->intermediate_rxbuffer);
-
+       kfree(info->intermediate_rxbuffer);
        info->intermediate_rxbuffer = NULL;
 
 }      /* end of mgsl_free_intermediate_rxbuffer_memory() */
@@ -4072,10 +4070,8 @@ static void mgsl_free_intermediate_txbuffer_memory(struct mgsl_struct *info)
        int i;
 
        for ( i=0; i<info->num_tx_holding_buffers; ++i ) {
-               if ( info->tx_holding_buffers[i].buffer ) {
-                               kfree(info->tx_holding_buffers[i].buffer);
-                               info->tx_holding_buffers[i].buffer=NULL;
-               }
+               kfree(info->tx_holding_buffers[i].buffer);
+               info->tx_holding_buffers[i].buffer = NULL;
        }
 
        info->get_tx_holding_index = 0;
index f185724448b142e6da58b3761e10ac74f85f9a05..7c063c5abc5596532b5aa2aec0c4586d40253210 100644 (file)
@@ -2788,10 +2788,8 @@ static void shutdown(SLMP_INFO * info)
        del_timer(&info->tx_timer);
        del_timer(&info->status_timer);
 
-       if (info->tx_buf) {
-               kfree(info->tx_buf);
-               info->tx_buf = NULL;
-       }
+       kfree(info->tx_buf);
+       info->tx_buf = NULL;
 
        spin_lock_irqsave(&info->lock,flags);
 
@@ -3611,8 +3609,7 @@ int alloc_tmp_rx_buf(SLMP_INFO *info)
 
 void free_tmp_rx_buf(SLMP_INFO *info)
 {
-       if (info->tmp_rx_buf)
-               kfree(info->tmp_rx_buf);
+       kfree(info->tmp_rx_buf);
        info->tmp_rx_buf = NULL;
 }
 
index c586bfa852eec510c2e486a331e4564655791fab..4b1eef51ec5926d97918331f20740c3664067375 100644 (file)
@@ -1416,14 +1416,11 @@ end_init:
 
        /* Release locally allocated memory ... nothing placed in slots */
 free_mem_out:
-       if (o_tp)
-               kfree(o_tp);
+       kfree(o_tp);
        if (o_tty)
                free_tty_struct(o_tty);
-       if (ltp)
-               kfree(ltp);
-       if (tp)
-               kfree(tp);
+       kfree(ltp);
+       kfree(tp);
        free_tty_struct(tty);
 
 fail_no_mem: