diff options
author | Jesper Juhl <jesper.juhl@gmail.com> | 2005-11-07 04:01:29 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-07 10:54:02 -0500 |
commit | 735d5661d5c5f023a78fbe68e771e261040ff1b7 (patch) | |
tree | b9865f0322d8e74661639f5f33b1897b23004659 | |
parent | fa671646f61182cd18234461a6e65f50c6558695 (diff) |
[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>
-rw-r--r-- | drivers/char/consolemap.c | 12 | ||||
-rw-r--r-- | drivers/char/drm/ffb_context.c | 6 | ||||
-rw-r--r-- | drivers/char/drm/ffb_drv.c | 6 | ||||
-rw-r--r-- | drivers/char/ip2/i2ellis.c | 4 | ||||
-rw-r--r-- | drivers/char/istallion.c | 7 | ||||
-rw-r--r-- | drivers/char/n_hdlc.c | 3 | ||||
-rw-r--r-- | drivers/char/pcmcia/synclink_cs.c | 3 | ||||
-rw-r--r-- | drivers/char/rocket.c | 6 | ||||
-rw-r--r-- | drivers/char/selection.c | 3 | ||||
-rw-r--r-- | drivers/char/stallion.c | 6 | ||||
-rw-r--r-- | drivers/char/synclink.c | 10 | ||||
-rw-r--r-- | drivers/char/synclinkmp.c | 9 | ||||
-rw-r--r-- | drivers/char/tty_io.c | 9 |
13 files changed, 29 insertions, 55 deletions
diff --git a/drivers/char/consolemap.c b/drivers/char/consolemap.c index 406dea914635..c85a4fa60da7 100644 --- a/drivers/char/consolemap.c +++ b/drivers/char/consolemap.c | |||
@@ -345,17 +345,15 @@ static void con_release_unimap(struct uni_pagedir *p) | |||
345 | for (i = 0; i < 32; i++) { | 345 | for (i = 0; i < 32; i++) { |
346 | if ((p1 = p->uni_pgdir[i]) != NULL) { | 346 | if ((p1 = p->uni_pgdir[i]) != NULL) { |
347 | for (j = 0; j < 32; j++) | 347 | for (j = 0; j < 32; j++) |
348 | if (p1[j]) | 348 | kfree(p1[j]); |
349 | kfree(p1[j]); | ||
350 | kfree(p1); | 349 | kfree(p1); |
351 | } | 350 | } |
352 | p->uni_pgdir[i] = NULL; | 351 | p->uni_pgdir[i] = NULL; |
353 | } | 352 | } |
354 | for (i = 0; i < 4; i++) | 353 | for (i = 0; i < 4; i++) { |
355 | if (p->inverse_translations[i]) { | 354 | kfree(p->inverse_translations[i]); |
356 | kfree(p->inverse_translations[i]); | 355 | p->inverse_translations[i] = NULL; |
357 | p->inverse_translations[i] = NULL; | 356 | } |
358 | } | ||
359 | } | 357 | } |
360 | 358 | ||
361 | void con_free_unimap(struct vc_data *vc) | 359 | void con_free_unimap(struct vc_data *vc) |
diff --git a/drivers/char/drm/ffb_context.c b/drivers/char/drm/ffb_context.c index 8a6cc2751bc9..1383727b443a 100644 --- a/drivers/char/drm/ffb_context.c +++ b/drivers/char/drm/ffb_context.c | |||
@@ -526,10 +526,8 @@ int ffb_driver_rmctx(struct inode *inode, struct file *filp, unsigned int cmd, | |||
526 | if (idx < 0 || idx >= FFB_MAX_CTXS) | 526 | if (idx < 0 || idx >= FFB_MAX_CTXS) |
527 | return -EINVAL; | 527 | return -EINVAL; |
528 | 528 | ||
529 | if (fpriv->hw_state[idx] != NULL) { | 529 | kfree(fpriv->hw_state[idx]); |
530 | kfree(fpriv->hw_state[idx]); | 530 | fpriv->hw_state[idx] = NULL; |
531 | fpriv->hw_state[idx] = NULL; | ||
532 | } | ||
533 | return 0; | 531 | return 0; |
534 | } | 532 | } |
535 | 533 | ||
diff --git a/drivers/char/drm/ffb_drv.c b/drivers/char/drm/ffb_drv.c index 5c121d6df9f2..c13f9abb41e9 100644 --- a/drivers/char/drm/ffb_drv.c +++ b/drivers/char/drm/ffb_drv.c | |||
@@ -245,14 +245,12 @@ static void ffb_driver_release(drm_device_t * dev, struct file *filp) | |||
245 | 245 | ||
246 | static void ffb_driver_pretakedown(drm_device_t * dev) | 246 | static void ffb_driver_pretakedown(drm_device_t * dev) |
247 | { | 247 | { |
248 | if (dev->dev_private) | 248 | kfree(dev->dev_private); |
249 | kfree(dev->dev_private); | ||
250 | } | 249 | } |
251 | 250 | ||
252 | static int ffb_driver_postcleanup(drm_device_t * dev) | 251 | static int ffb_driver_postcleanup(drm_device_t * dev) |
253 | { | 252 | { |
254 | if (ffb_position != NULL) | 253 | kfree(ffb_position); |
255 | kfree(ffb_position); | ||
256 | return 0; | 254 | return 0; |
257 | } | 255 | } |
258 | 256 | ||
diff --git a/drivers/char/ip2/i2ellis.c b/drivers/char/ip2/i2ellis.c index f834d05ccc97..dd761a1e4f08 100644 --- a/drivers/char/ip2/i2ellis.c +++ b/drivers/char/ip2/i2ellis.c | |||
@@ -106,9 +106,7 @@ iiEllisInit(void) | |||
106 | static void | 106 | static void |
107 | iiEllisCleanup(void) | 107 | iiEllisCleanup(void) |
108 | { | 108 | { |
109 | if ( pDelayTimer != NULL ) { | 109 | kfree(pDelayTimer); |
110 | kfree ( pDelayTimer ); | ||
111 | } | ||
112 | } | 110 | } |
113 | 111 | ||
114 | //****************************************************************************** | 112 | //****************************************************************************** |
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c index e3ddbdb85a2f..ce3bc0d45f1f 100644 --- a/drivers/char/istallion.c +++ b/drivers/char/istallion.c | |||
@@ -860,10 +860,9 @@ static void __exit istallion_module_exit(void) | |||
860 | if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem"))) | 860 | if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem"))) |
861 | printk("STALLION: failed to un-register serial memory device, " | 861 | printk("STALLION: failed to un-register serial memory device, " |
862 | "errno=%d\n", -i); | 862 | "errno=%d\n", -i); |
863 | if (stli_tmpwritebuf != (char *) NULL) | 863 | |
864 | kfree(stli_tmpwritebuf); | 864 | kfree(stli_tmpwritebuf); |
865 | if (stli_txcookbuf != (char *) NULL) | 865 | kfree(stli_txcookbuf); |
866 | kfree(stli_txcookbuf); | ||
867 | 866 | ||
868 | for (i = 0; (i < stli_nrbrds); i++) { | 867 | for (i = 0; (i < stli_nrbrds); i++) { |
869 | if ((brdp = stli_brds[i]) == (stlibrd_t *) NULL) | 868 | if ((brdp = stli_brds[i]) == (stlibrd_t *) NULL) |
diff --git a/drivers/char/n_hdlc.c b/drivers/char/n_hdlc.c index 5079beda69b5..c3660d8781a4 100644 --- a/drivers/char/n_hdlc.c +++ b/drivers/char/n_hdlc.c | |||
@@ -264,8 +264,7 @@ static void n_hdlc_release(struct n_hdlc *n_hdlc) | |||
264 | } else | 264 | } else |
265 | break; | 265 | break; |
266 | } | 266 | } |
267 | if (n_hdlc->tbuf) | 267 | kfree(n_hdlc->tbuf); |
268 | kfree(n_hdlc->tbuf); | ||
269 | kfree(n_hdlc); | 268 | kfree(n_hdlc); |
270 | 269 | ||
271 | } /* end of n_hdlc_release() */ | 270 | } /* end of n_hdlc_release() */ |
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 02d7f046c10a..2c326ea53421 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c | |||
@@ -2994,8 +2994,7 @@ int rx_alloc_buffers(MGSLPC_INFO *info) | |||
2994 | 2994 | ||
2995 | void rx_free_buffers(MGSLPC_INFO *info) | 2995 | void rx_free_buffers(MGSLPC_INFO *info) |
2996 | { | 2996 | { |
2997 | if (info->rx_buf) | 2997 | kfree(info->rx_buf); |
2998 | kfree(info->rx_buf); | ||
2999 | info->rx_buf = NULL; | 2998 | info->rx_buf = NULL; |
3000 | } | 2999 | } |
3001 | 3000 | ||
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c index 928b850cc679..d3bc731fbb27 100644 --- a/drivers/char/rocket.c +++ b/drivers/char/rocket.c | |||
@@ -2512,10 +2512,8 @@ static void rp_cleanup_module(void) | |||
2512 | "rocketport driver\n", -retval); | 2512 | "rocketport driver\n", -retval); |
2513 | put_tty_driver(rocket_driver); | 2513 | put_tty_driver(rocket_driver); |
2514 | 2514 | ||
2515 | for (i = 0; i < MAX_RP_PORTS; i++) { | 2515 | for (i = 0; i < MAX_RP_PORTS; i++) |
2516 | if (rp_table[i]) | 2516 | kfree(rp_table[i]); |
2517 | kfree(rp_table[i]); | ||
2518 | } | ||
2519 | 2517 | ||
2520 | for (i = 0; i < NUM_BOARDS; i++) { | 2518 | for (i = 0; i < NUM_BOARDS; i++) { |
2521 | if (rcktpt_io_addr[i] <= 0 || is_PCI[i]) | 2519 | if (rcktpt_io_addr[i] <= 0 || is_PCI[i]) |
diff --git a/drivers/char/selection.c b/drivers/char/selection.c index 16d630f58bb4..5b187c895c18 100644 --- a/drivers/char/selection.c +++ b/drivers/char/selection.c | |||
@@ -246,8 +246,7 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t | |||
246 | clear_selection(); | 246 | clear_selection(); |
247 | return -ENOMEM; | 247 | return -ENOMEM; |
248 | } | 248 | } |
249 | if (sel_buffer) | 249 | kfree(sel_buffer); |
250 | kfree(sel_buffer); | ||
251 | sel_buffer = bp; | 250 | sel_buffer = bp; |
252 | 251 | ||
253 | obp = bp; | 252 | obp = bp; |
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c index 1c686414e0a1..95af2a941595 100644 --- a/drivers/char/stallion.c +++ b/drivers/char/stallion.c | |||
@@ -785,8 +785,7 @@ static void __exit stallion_module_exit(void) | |||
785 | "errno=%d\n", -i); | 785 | "errno=%d\n", -i); |
786 | class_destroy(stallion_class); | 786 | class_destroy(stallion_class); |
787 | 787 | ||
788 | if (stl_tmpwritebuf != (char *) NULL) | 788 | kfree(stl_tmpwritebuf); |
789 | kfree(stl_tmpwritebuf); | ||
790 | 789 | ||
791 | for (i = 0; (i < stl_nrbrds); i++) { | 790 | for (i = 0; (i < stl_nrbrds); i++) { |
792 | if ((brdp = stl_brds[i]) == (stlbrd_t *) NULL) | 791 | if ((brdp = stl_brds[i]) == (stlbrd_t *) NULL) |
@@ -804,8 +803,7 @@ static void __exit stallion_module_exit(void) | |||
804 | continue; | 803 | continue; |
805 | if (portp->tty != (struct tty_struct *) NULL) | 804 | if (portp->tty != (struct tty_struct *) NULL) |
806 | stl_hangup(portp->tty); | 805 | stl_hangup(portp->tty); |
807 | if (portp->tx.buf != (char *) NULL) | 806 | kfree(portp->tx.buf); |
808 | kfree(portp->tx.buf); | ||
809 | kfree(portp); | 807 | kfree(portp); |
810 | } | 808 | } |
811 | kfree(panelp); | 809 | kfree(panelp); |
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index 0133dc0e25d0..5d1ffa3bd4c3 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c | |||
@@ -4016,9 +4016,7 @@ static int mgsl_alloc_intermediate_rxbuffer_memory(struct mgsl_struct *info) | |||
4016 | */ | 4016 | */ |
4017 | static void mgsl_free_intermediate_rxbuffer_memory(struct mgsl_struct *info) | 4017 | static void mgsl_free_intermediate_rxbuffer_memory(struct mgsl_struct *info) |
4018 | { | 4018 | { |
4019 | if ( info->intermediate_rxbuffer ) | 4019 | kfree(info->intermediate_rxbuffer); |
4020 | kfree(info->intermediate_rxbuffer); | ||
4021 | |||
4022 | info->intermediate_rxbuffer = NULL; | 4020 | info->intermediate_rxbuffer = NULL; |
4023 | 4021 | ||
4024 | } /* end of mgsl_free_intermediate_rxbuffer_memory() */ | 4022 | } /* end of mgsl_free_intermediate_rxbuffer_memory() */ |
@@ -4072,10 +4070,8 @@ static void mgsl_free_intermediate_txbuffer_memory(struct mgsl_struct *info) | |||
4072 | int i; | 4070 | int i; |
4073 | 4071 | ||
4074 | for ( i=0; i<info->num_tx_holding_buffers; ++i ) { | 4072 | for ( i=0; i<info->num_tx_holding_buffers; ++i ) { |
4075 | if ( info->tx_holding_buffers[i].buffer ) { | 4073 | kfree(info->tx_holding_buffers[i].buffer); |
4076 | kfree(info->tx_holding_buffers[i].buffer); | 4074 | info->tx_holding_buffers[i].buffer = NULL; |
4077 | info->tx_holding_buffers[i].buffer=NULL; | ||
4078 | } | ||
4079 | } | 4075 | } |
4080 | 4076 | ||
4081 | info->get_tx_holding_index = 0; | 4077 | info->get_tx_holding_index = 0; |
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index f185724448b1..7c063c5abc55 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c | |||
@@ -2788,10 +2788,8 @@ static void shutdown(SLMP_INFO * info) | |||
2788 | del_timer(&info->tx_timer); | 2788 | del_timer(&info->tx_timer); |
2789 | del_timer(&info->status_timer); | 2789 | del_timer(&info->status_timer); |
2790 | 2790 | ||
2791 | if (info->tx_buf) { | 2791 | kfree(info->tx_buf); |
2792 | kfree(info->tx_buf); | 2792 | info->tx_buf = NULL; |
2793 | info->tx_buf = NULL; | ||
2794 | } | ||
2795 | 2793 | ||
2796 | spin_lock_irqsave(&info->lock,flags); | 2794 | spin_lock_irqsave(&info->lock,flags); |
2797 | 2795 | ||
@@ -3611,8 +3609,7 @@ int alloc_tmp_rx_buf(SLMP_INFO *info) | |||
3611 | 3609 | ||
3612 | void free_tmp_rx_buf(SLMP_INFO *info) | 3610 | void free_tmp_rx_buf(SLMP_INFO *info) |
3613 | { | 3611 | { |
3614 | if (info->tmp_rx_buf) | 3612 | kfree(info->tmp_rx_buf); |
3615 | kfree(info->tmp_rx_buf); | ||
3616 | info->tmp_rx_buf = NULL; | 3613 | info->tmp_rx_buf = NULL; |
3617 | } | 3614 | } |
3618 | 3615 | ||
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index c586bfa852ee..4b1eef51ec59 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -1416,14 +1416,11 @@ end_init: | |||
1416 | 1416 | ||
1417 | /* Release locally allocated memory ... nothing placed in slots */ | 1417 | /* Release locally allocated memory ... nothing placed in slots */ |
1418 | free_mem_out: | 1418 | free_mem_out: |
1419 | if (o_tp) | 1419 | kfree(o_tp); |
1420 | kfree(o_tp); | ||
1421 | if (o_tty) | 1420 | if (o_tty) |
1422 | free_tty_struct(o_tty); | 1421 | free_tty_struct(o_tty); |
1423 | if (ltp) | 1422 | kfree(ltp); |
1424 | kfree(ltp); | 1423 | kfree(tp); |
1425 | if (tp) | ||
1426 | kfree(tp); | ||
1427 | free_tty_struct(tty); | 1424 | free_tty_struct(tty); |
1428 | 1425 | ||
1429 | fail_no_mem: | 1426 | fail_no_mem: |