Commit 735d5661 authored by Jesper Juhl's avatar Jesper Juhl Committed by Linus Torvalds

[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: default avatarJesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent fa671646
...@@ -345,17 +345,15 @@ static void con_release_unimap(struct uni_pagedir *p) ...@@ -345,17 +345,15 @@ static void con_release_unimap(struct uni_pagedir *p)
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
if ((p1 = p->uni_pgdir[i]) != NULL) { if ((p1 = p->uni_pgdir[i]) != NULL) {
for (j = 0; j < 32; j++) for (j = 0; j < 32; j++)
if (p1[j]) kfree(p1[j]);
kfree(p1[j]);
kfree(p1); kfree(p1);
} }
p->uni_pgdir[i] = NULL; p->uni_pgdir[i] = NULL;
} }
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++) {
if (p->inverse_translations[i]) { kfree(p->inverse_translations[i]);
kfree(p->inverse_translations[i]); p->inverse_translations[i] = NULL;
p->inverse_translations[i] = NULL; }
}
} }
void con_free_unimap(struct vc_data *vc) void con_free_unimap(struct vc_data *vc)
......
...@@ -526,10 +526,8 @@ int ffb_driver_rmctx(struct inode *inode, struct file *filp, unsigned int cmd, ...@@ -526,10 +526,8 @@ int ffb_driver_rmctx(struct inode *inode, struct file *filp, unsigned int cmd,
if (idx < 0 || idx >= FFB_MAX_CTXS) if (idx < 0 || idx >= FFB_MAX_CTXS)
return -EINVAL; return -EINVAL;
if (fpriv->hw_state[idx] != NULL) { kfree(fpriv->hw_state[idx]);
kfree(fpriv->hw_state[idx]); fpriv->hw_state[idx] = NULL;
fpriv->hw_state[idx] = NULL;
}
return 0; return 0;
} }
......
...@@ -245,14 +245,12 @@ static void ffb_driver_release(drm_device_t * dev, struct file *filp) ...@@ -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) 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) static int ffb_driver_postcleanup(drm_device_t * dev)
{ {
if (ffb_position != NULL) kfree(ffb_position);
kfree(ffb_position);
return 0; return 0;
} }
......
...@@ -106,9 +106,7 @@ iiEllisInit(void) ...@@ -106,9 +106,7 @@ iiEllisInit(void)
static void static void
iiEllisCleanup(void) iiEllisCleanup(void)
{ {
if ( pDelayTimer != NULL ) { kfree(pDelayTimer);
kfree ( pDelayTimer );
}
} }
//****************************************************************************** //******************************************************************************
......
...@@ -860,10 +860,9 @@ static void __exit istallion_module_exit(void) ...@@ -860,10 +860,9 @@ static void __exit istallion_module_exit(void)
if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem"))) if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem")))
printk("STALLION: failed to un-register serial memory device, " printk("STALLION: failed to un-register serial memory device, "
"errno=%d\n", -i); "errno=%d\n", -i);
if (stli_tmpwritebuf != (char *) NULL)
kfree(stli_tmpwritebuf); kfree(stli_tmpwritebuf);
if (stli_txcookbuf != (char *) NULL) kfree(stli_txcookbuf);
kfree(stli_txcookbuf);
for (i = 0; (i < stli_nrbrds); i++) { for (i = 0; (i < stli_nrbrds); i++) {
if ((brdp = stli_brds[i]) == (stlibrd_t *) NULL) if ((brdp = stli_brds[i]) == (stlibrd_t *) NULL)
......
...@@ -264,8 +264,7 @@ static void n_hdlc_release(struct n_hdlc *n_hdlc) ...@@ -264,8 +264,7 @@ static void n_hdlc_release(struct n_hdlc *n_hdlc)
} else } else
break; break;
} }
if (n_hdlc->tbuf) kfree(n_hdlc->tbuf);
kfree(n_hdlc->tbuf);
kfree(n_hdlc); kfree(n_hdlc);
} /* end of n_hdlc_release() */ } /* end of n_hdlc_release() */
......
...@@ -2994,8 +2994,7 @@ int rx_alloc_buffers(MGSLPC_INFO *info) ...@@ -2994,8 +2994,7 @@ int rx_alloc_buffers(MGSLPC_INFO *info)
void rx_free_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; info->rx_buf = NULL;
} }
......
...@@ -2512,10 +2512,8 @@ static void rp_cleanup_module(void) ...@@ -2512,10 +2512,8 @@ static void rp_cleanup_module(void)
"rocketport driver\n", -retval); "rocketport driver\n", -retval);
put_tty_driver(rocket_driver); put_tty_driver(rocket_driver);
for (i = 0; i < MAX_RP_PORTS; i++) { for (i = 0; i < MAX_RP_PORTS; i++)
if (rp_table[i]) kfree(rp_table[i]);
kfree(rp_table[i]);
}
for (i = 0; i < NUM_BOARDS; i++) { for (i = 0; i < NUM_BOARDS; i++) {
if (rcktpt_io_addr[i] <= 0 || is_PCI[i]) if (rcktpt_io_addr[i] <= 0 || is_PCI[i])
......
...@@ -246,8 +246,7 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t ...@@ -246,8 +246,7 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t
clear_selection(); clear_selection();
return -ENOMEM; return -ENOMEM;
} }
if (sel_buffer) kfree(sel_buffer);
kfree(sel_buffer);
sel_buffer = bp; sel_buffer = bp;
obp = bp; obp = bp;
......
...@@ -785,8 +785,7 @@ static void __exit stallion_module_exit(void) ...@@ -785,8 +785,7 @@ static void __exit stallion_module_exit(void)
"errno=%d\n", -i); "errno=%d\n", -i);
class_destroy(stallion_class); class_destroy(stallion_class);
if (stl_tmpwritebuf != (char *) NULL) kfree(stl_tmpwritebuf);
kfree(stl_tmpwritebuf);
for (i = 0; (i < stl_nrbrds); i++) { for (i = 0; (i < stl_nrbrds); i++) {
if ((brdp = stl_brds[i]) == (stlbrd_t *) NULL) if ((brdp = stl_brds[i]) == (stlbrd_t *) NULL)
...@@ -804,8 +803,7 @@ static void __exit stallion_module_exit(void) ...@@ -804,8 +803,7 @@ static void __exit stallion_module_exit(void)
continue; continue;
if (portp->tty != (struct tty_struct *) NULL) if (portp->tty != (struct tty_struct *) NULL)
stl_hangup(portp->tty); stl_hangup(portp->tty);
if (portp->tx.buf != (char *) NULL) kfree(portp->tx.buf);
kfree(portp->tx.buf);
kfree(portp); kfree(portp);
} }
kfree(panelp); kfree(panelp);
......
...@@ -4016,9 +4016,7 @@ static int mgsl_alloc_intermediate_rxbuffer_memory(struct mgsl_struct *info) ...@@ -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) 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; info->intermediate_rxbuffer = NULL;
} /* end of mgsl_free_intermediate_rxbuffer_memory() */ } /* end of mgsl_free_intermediate_rxbuffer_memory() */
...@@ -4072,10 +4070,8 @@ static void mgsl_free_intermediate_txbuffer_memory(struct mgsl_struct *info) ...@@ -4072,10 +4070,8 @@ static void mgsl_free_intermediate_txbuffer_memory(struct mgsl_struct *info)
int i; int i;
for ( i=0; i<info->num_tx_holding_buffers; ++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);
kfree(info->tx_holding_buffers[i].buffer); info->tx_holding_buffers[i].buffer = NULL;
info->tx_holding_buffers[i].buffer=NULL;
}
} }
info->get_tx_holding_index = 0; info->get_tx_holding_index = 0;
......
...@@ -2788,10 +2788,8 @@ static void shutdown(SLMP_INFO * info) ...@@ -2788,10 +2788,8 @@ static void shutdown(SLMP_INFO * info)
del_timer(&info->tx_timer); del_timer(&info->tx_timer);
del_timer(&info->status_timer); del_timer(&info->status_timer);
if (info->tx_buf) { kfree(info->tx_buf);
kfree(info->tx_buf); info->tx_buf = NULL;
info->tx_buf = NULL;
}
spin_lock_irqsave(&info->lock,flags); spin_lock_irqsave(&info->lock,flags);
...@@ -3611,8 +3609,7 @@ int alloc_tmp_rx_buf(SLMP_INFO *info) ...@@ -3611,8 +3609,7 @@ int alloc_tmp_rx_buf(SLMP_INFO *info)
void free_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; info->tmp_rx_buf = NULL;
} }
......
...@@ -1416,14 +1416,11 @@ static int init_dev(struct tty_driver *driver, int idx, ...@@ -1416,14 +1416,11 @@ static int init_dev(struct tty_driver *driver, int idx,
/* Release locally allocated memory ... nothing placed in slots */ /* Release locally allocated memory ... nothing placed in slots */
free_mem_out: free_mem_out:
if (o_tp) kfree(o_tp);
kfree(o_tp);
if (o_tty) if (o_tty)
free_tty_struct(o_tty); free_tty_struct(o_tty);
if (ltp) kfree(ltp);
kfree(ltp); kfree(tp);
if (tp)
kfree(tp);
free_tty_struct(tty); free_tty_struct(tty);
fail_no_mem: fail_no_mem:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment