Commit 735d5661d5c5f023a78fbe68e771e261040ff1b7

Authored by Jesper Juhl
Committed by Linus Torvalds
1 parent fa671646f6

[PATCH] kfree cleanup: drivers/char

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>

Showing 13 changed files with 29 additions and 55 deletions Side-by-side Diff

drivers/char/consolemap.c
... ... @@ -345,17 +345,15 @@
345 345 for (i = 0; i < 32; i++) {
346 346 if ((p1 = p->uni_pgdir[i]) != NULL) {
347 347 for (j = 0; j < 32; j++)
348   - if (p1[j])
349   - kfree(p1[j]);
  348 + kfree(p1[j]);
350 349 kfree(p1);
351 350 }
352 351 p->uni_pgdir[i] = NULL;
353 352 }
354   - for (i = 0; i < 4; i++)
355   - if (p->inverse_translations[i]) {
356   - kfree(p->inverse_translations[i]);
357   - p->inverse_translations[i] = NULL;
358   - }
  353 + for (i = 0; i < 4; i++) {
  354 + kfree(p->inverse_translations[i]);
  355 + p->inverse_translations[i] = NULL;
  356 + }
359 357 }
360 358  
361 359 void con_free_unimap(struct vc_data *vc)
drivers/char/drm/ffb_context.c
... ... @@ -526,10 +526,8 @@
526 526 if (idx < 0 || idx >= FFB_MAX_CTXS)
527 527 return -EINVAL;
528 528  
529   - if (fpriv->hw_state[idx] != NULL) {
530   - kfree(fpriv->hw_state[idx]);
531   - fpriv->hw_state[idx] = NULL;
532   - }
  529 + kfree(fpriv->hw_state[idx]);
  530 + fpriv->hw_state[idx] = NULL;
533 531 return 0;
534 532 }
535 533  
drivers/char/drm/ffb_drv.c
... ... @@ -245,14 +245,12 @@
245 245  
246 246 static void ffb_driver_pretakedown(drm_device_t * dev)
247 247 {
248   - if (dev->dev_private)
249   - kfree(dev->dev_private);
  248 + kfree(dev->dev_private);
250 249 }
251 250  
252 251 static int ffb_driver_postcleanup(drm_device_t * dev)
253 252 {
254   - if (ffb_position != NULL)
255   - kfree(ffb_position);
  253 + kfree(ffb_position);
256 254 return 0;
257 255 }
258 256  
drivers/char/ip2/i2ellis.c
... ... @@ -106,9 +106,7 @@
106 106 static void
107 107 iiEllisCleanup(void)
108 108 {
109   - if ( pDelayTimer != NULL ) {
110   - kfree ( pDelayTimer );
111   - }
  109 + kfree(pDelayTimer);
112 110 }
113 111  
114 112 //******************************************************************************
drivers/char/istallion.c
... ... @@ -860,10 +860,9 @@
860 860 if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem")))
861 861 printk("STALLION: failed to un-register serial memory device, "
862 862 "errno=%d\n", -i);
863   - if (stli_tmpwritebuf != (char *) NULL)
864   - kfree(stli_tmpwritebuf);
865   - if (stli_txcookbuf != (char *) NULL)
866   - kfree(stli_txcookbuf);
  863 +
  864 + kfree(stli_tmpwritebuf);
  865 + kfree(stli_txcookbuf);
867 866  
868 867 for (i = 0; (i < stli_nrbrds); i++) {
869 868 if ((brdp = stli_brds[i]) == (stlibrd_t *) NULL)
drivers/char/n_hdlc.c
... ... @@ -264,8 +264,7 @@
264 264 } else
265 265 break;
266 266 }
267   - if (n_hdlc->tbuf)
268   - kfree(n_hdlc->tbuf);
  267 + kfree(n_hdlc->tbuf);
269 268 kfree(n_hdlc);
270 269  
271 270 } /* end of n_hdlc_release() */
drivers/char/pcmcia/synclink_cs.c
... ... @@ -2994,8 +2994,7 @@
2994 2994  
2995 2995 void rx_free_buffers(MGSLPC_INFO *info)
2996 2996 {
2997   - if (info->rx_buf)
2998   - kfree(info->rx_buf);
  2997 + kfree(info->rx_buf);
2999 2998 info->rx_buf = NULL;
3000 2999 }
3001 3000  
drivers/char/rocket.c
... ... @@ -2512,10 +2512,8 @@
2512 2512 "rocketport driver\n", -retval);
2513 2513 put_tty_driver(rocket_driver);
2514 2514  
2515   - for (i = 0; i < MAX_RP_PORTS; i++) {
2516   - if (rp_table[i])
2517   - kfree(rp_table[i]);
2518   - }
  2515 + for (i = 0; i < MAX_RP_PORTS; i++)
  2516 + kfree(rp_table[i]);
2519 2517  
2520 2518 for (i = 0; i < NUM_BOARDS; i++) {
2521 2519 if (rcktpt_io_addr[i] <= 0 || is_PCI[i])
drivers/char/selection.c
... ... @@ -246,8 +246,7 @@
246 246 clear_selection();
247 247 return -ENOMEM;
248 248 }
249   - if (sel_buffer)
250   - kfree(sel_buffer);
  249 + kfree(sel_buffer);
251 250 sel_buffer = bp;
252 251  
253 252 obp = bp;
drivers/char/stallion.c
... ... @@ -785,8 +785,7 @@
785 785 "errno=%d\n", -i);
786 786 class_destroy(stallion_class);
787 787  
788   - if (stl_tmpwritebuf != (char *) NULL)
789   - kfree(stl_tmpwritebuf);
  788 + kfree(stl_tmpwritebuf);
790 789  
791 790 for (i = 0; (i < stl_nrbrds); i++) {
792 791 if ((brdp = stl_brds[i]) == (stlbrd_t *) NULL)
... ... @@ -804,8 +803,7 @@
804 803 continue;
805 804 if (portp->tty != (struct tty_struct *) NULL)
806 805 stl_hangup(portp->tty);
807   - if (portp->tx.buf != (char *) NULL)
808   - kfree(portp->tx.buf);
  806 + kfree(portp->tx.buf);
809 807 kfree(portp);
810 808 }
811 809 kfree(panelp);
drivers/char/synclink.c
... ... @@ -4016,9 +4016,7 @@
4016 4016 */
4017 4017 static void mgsl_free_intermediate_rxbuffer_memory(struct mgsl_struct *info)
4018 4018 {
4019   - if ( info->intermediate_rxbuffer )
4020   - kfree(info->intermediate_rxbuffer);
4021   -
  4019 + kfree(info->intermediate_rxbuffer);
4022 4020 info->intermediate_rxbuffer = NULL;
4023 4021  
4024 4022 } /* end of mgsl_free_intermediate_rxbuffer_memory() */
... ... @@ -4072,10 +4070,8 @@
4072 4070 int i;
4073 4071  
4074 4072 for ( i=0; i<info->num_tx_holding_buffers; ++i ) {
4075   - if ( info->tx_holding_buffers[i].buffer ) {
4076   - kfree(info->tx_holding_buffers[i].buffer);
4077   - info->tx_holding_buffers[i].buffer=NULL;
4078   - }
  4073 + kfree(info->tx_holding_buffers[i].buffer);
  4074 + info->tx_holding_buffers[i].buffer = NULL;
4079 4075 }
4080 4076  
4081 4077 info->get_tx_holding_index = 0;
drivers/char/synclinkmp.c
... ... @@ -2788,10 +2788,8 @@
2788 2788 del_timer(&info->tx_timer);
2789 2789 del_timer(&info->status_timer);
2790 2790  
2791   - if (info->tx_buf) {
2792   - kfree(info->tx_buf);
2793   - info->tx_buf = NULL;
2794   - }
  2791 + kfree(info->tx_buf);
  2792 + info->tx_buf = NULL;
2795 2793  
2796 2794 spin_lock_irqsave(&info->lock,flags);
2797 2795  
... ... @@ -3611,8 +3609,7 @@
3611 3609  
3612 3610 void free_tmp_rx_buf(SLMP_INFO *info)
3613 3611 {
3614   - if (info->tmp_rx_buf)
3615   - kfree(info->tmp_rx_buf);
  3612 + kfree(info->tmp_rx_buf);
3616 3613 info->tmp_rx_buf = NULL;
3617 3614 }
3618 3615  
drivers/char/tty_io.c
... ... @@ -1416,14 +1416,11 @@
1416 1416  
1417 1417 /* Release locally allocated memory ... nothing placed in slots */
1418 1418 free_mem_out:
1419   - if (o_tp)
1420   - kfree(o_tp);
  1419 + kfree(o_tp);
1421 1420 if (o_tty)
1422 1421 free_tty_struct(o_tty);
1423   - if (ltp)
1424   - kfree(ltp);
1425   - if (tp)
1426   - kfree(tp);
  1422 + kfree(ltp);
  1423 + kfree(tp);
1427 1424 free_tty_struct(tty);
1428 1425  
1429 1426 fail_no_mem: