提交 8f760780 编写于 作者: J Jesper Juhl 提交者: Linus Torvalds

[PATCH] Remove redundant NULL checks before [kv]free - in drivers/

Remove redundant NULL chck before kfree + tiny CodingStyle cleanup for
drivers/
Signed-off-by: NJesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 9a66a53f
...@@ -329,9 +329,8 @@ static int __devinit agp_sgi_init(void) ...@@ -329,9 +329,8 @@ static int __devinit agp_sgi_init(void)
static void __devexit agp_sgi_cleanup(void) static void __devexit agp_sgi_cleanup(void)
{ {
if (sgi_tioca_agp_bridges) kfree(sgi_tioca_agp_bridges);
kfree(sgi_tioca_agp_bridges); sgi_tioca_agp_bridges = NULL;
sgi_tioca_agp_bridges=NULL;
} }
module_init(agp_sgi_init); module_init(agp_sgi_init);
......
...@@ -1320,11 +1320,12 @@ static struct tty_operations hvcs_ops = { ...@@ -1320,11 +1320,12 @@ static struct tty_operations hvcs_ops = {
static int hvcs_alloc_index_list(int n) static int hvcs_alloc_index_list(int n)
{ {
int i; int i;
hvcs_index_list = kmalloc(n * sizeof(hvcs_index_count),GFP_KERNEL); hvcs_index_list = kmalloc(n * sizeof(hvcs_index_count),GFP_KERNEL);
if (!hvcs_index_list) if (!hvcs_index_list)
return -ENOMEM; return -ENOMEM;
hvcs_index_count = n; hvcs_index_count = n;
for(i = 0; i < hvcs_index_count; i++) for (i = 0; i < hvcs_index_count; i++)
hvcs_index_list[i] = -1; hvcs_index_list[i] = -1;
return 0; return 0;
} }
...@@ -1332,11 +1333,9 @@ static int hvcs_alloc_index_list(int n) ...@@ -1332,11 +1333,9 @@ static int hvcs_alloc_index_list(int n)
static void hvcs_free_index_list(void) static void hvcs_free_index_list(void)
{ {
/* Paranoia check to be thorough. */ /* Paranoia check to be thorough. */
if (hvcs_index_list) { kfree(hvcs_index_list);
kfree(hvcs_index_list); hvcs_index_list = NULL;
hvcs_index_list = NULL; hvcs_index_count = 0;
hvcs_index_count = 0;
}
} }
static int __init hvcs_module_init(void) static int __init hvcs_module_init(void)
......
...@@ -305,10 +305,8 @@ mptfc_GetFcDevPage0(MPT_ADAPTER *ioc, int ioc_port, ...@@ -305,10 +305,8 @@ mptfc_GetFcDevPage0(MPT_ADAPTER *ioc, int ioc_port,
} }
out: out:
if (pp0_array) kfree(pp0_array);
kfree(pp0_array); kfree(p0_array);
if (p0_array)
kfree(p0_array);
return rc; return rc;
} }
......
...@@ -1378,8 +1378,7 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc) ...@@ -1378,8 +1378,7 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc)
return 0; return 0;
out_free_port_info: out_free_port_info:
if (hba) kfree(hba);
kfree(hba);
out: out:
return error; return error;
} }
......
...@@ -431,8 +431,7 @@ static struct fs_enet_mii_bus *create_bus(const struct fs_mii_bus_info *bi) ...@@ -431,8 +431,7 @@ static struct fs_enet_mii_bus *create_bus(const struct fs_mii_bus_info *bi)
return bus; return bus;
err: err:
if (bus) kfree(bus);
kfree(bus);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
......
...@@ -1229,12 +1229,6 @@ static struct ipw_fw_error *ipw_alloc_error_log(struct ipw_priv *priv) ...@@ -1229,12 +1229,6 @@ static struct ipw_fw_error *ipw_alloc_error_log(struct ipw_priv *priv)
return error; return error;
} }
static void ipw_free_error_log(struct ipw_fw_error *error)
{
if (error)
kfree(error);
}
static ssize_t show_event_log(struct device *d, static ssize_t show_event_log(struct device *d,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
...@@ -1296,10 +1290,9 @@ static ssize_t clear_error(struct device *d, ...@@ -1296,10 +1290,9 @@ static ssize_t clear_error(struct device *d,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct ipw_priv *priv = dev_get_drvdata(d); struct ipw_priv *priv = dev_get_drvdata(d);
if (priv->error) {
ipw_free_error_log(priv->error); kfree(priv->error);
priv->error = NULL; priv->error = NULL;
}
return count; return count;
} }
...@@ -1970,8 +1963,7 @@ static void ipw_irq_tasklet(struct ipw_priv *priv) ...@@ -1970,8 +1963,7 @@ static void ipw_irq_tasklet(struct ipw_priv *priv)
struct ipw_fw_error *error = struct ipw_fw_error *error =
ipw_alloc_error_log(priv); ipw_alloc_error_log(priv);
ipw_dump_error_log(priv, error); ipw_dump_error_log(priv, error);
if (error) kfree(error);
ipw_free_error_log(error);
} }
#endif #endif
} else { } else {
...@@ -11693,10 +11685,8 @@ static void ipw_pci_remove(struct pci_dev *pdev) ...@@ -11693,10 +11685,8 @@ static void ipw_pci_remove(struct pci_dev *pdev)
} }
} }
if (priv->error) { kfree(priv->error);
ipw_free_error_log(priv->error); priv->error = NULL;
priv->error = NULL;
}
#ifdef CONFIG_IPW2200_PROMISCUOUS #ifdef CONFIG_IPW2200_PROMISCUOUS
ipw_prom_free(priv); ipw_prom_free(priv);
......
...@@ -222,9 +222,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) ...@@ -222,9 +222,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
&& copy_to_user(arg + sizeof(args), argbuf, argsize)) && copy_to_user(arg + sizeof(args), argbuf, argsize))
rc = -EFAULT; rc = -EFAULT;
error: error:
if (argbuf) kfree(argbuf);
kfree(argbuf);
return rc; return rc;
} }
......
...@@ -743,8 +743,7 @@ void __exit au1100fb_cleanup(void) ...@@ -743,8 +743,7 @@ void __exit au1100fb_cleanup(void)
{ {
driver_unregister(&au1100fb_driver); driver_unregister(&au1100fb_driver);
if (drv_info.opt_mode) kfree(drv_info.opt_mode);
kfree(drv_info.opt_mode);
} }
module_init(au1100fb_init); module_init(au1100fb_init);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册