Commit 735d5661d5c5f023a78fbe68e771e261040ff1b7
Committed by
Linus Torvalds
1 parent
fa671646f6
Exists in
master
and in
7 other branches
[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
- 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
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
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
drivers/char/pcmcia/synclink_cs.c
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
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: |