bos@19: bos@19: From: Jesper Juhl bos@19: bos@19: Remove redundant NULL chck before kfree + tiny CodingStyle cleanup for bos@19: drivers/ bos@19: bos@19: Signed-off-by: Jesper Juhl bos@19: Signed-off-by: Andrew Morton bos@19: --- bos@19: bos@19: drivers/char/agp/sgi-agp.c | 5 ++--- bos@19: drivers/char/hvcs.c | 11 +++++------ bos@19: drivers/message/fusion/mptfc.c | 6 ++---- bos@19: drivers/message/fusion/mptsas.c | 3 +-- bos@19: drivers/net/fs_enet/fs_enet-mii.c | 3 +-- bos@19: drivers/net/wireless/ipw2200.c | 22 ++++++---------------- bos@19: drivers/scsi/libata-scsi.c | 4 +--- bos@19: drivers/video/au1100fb.c | 3 +-- bos@19: 8 files changed, 19 insertions(+), 38 deletions(-) bos@19: bos@19: diff -puN drivers/char/agp/sgi-agp.c~remove-redundant-null-checks-before-free-in-drivers drivers/char/agp/sgi-agp.c bos@19: --- a/drivers/char/agp/sgi-agp.c~remove-redundant-null-checks-before-free-in-drivers bos@19: +++ a/drivers/char/agp/sgi-agp.c bos@19: @@ -329,9 +329,8 @@ static int __devinit agp_sgi_init(void) bos@19: bos@19: static void __devexit agp_sgi_cleanup(void) bos@19: { bos@19: - if (sgi_tioca_agp_bridges) bos@19: - kfree(sgi_tioca_agp_bridges); bos@19: - sgi_tioca_agp_bridges=NULL; bos@19: + kfree(sgi_tioca_agp_bridges); bos@19: + sgi_tioca_agp_bridges = NULL; bos@19: } bos@19: bos@19: module_init(agp_sgi_init); bos@19: diff -puN drivers/char/hvcs.c~remove-redundant-null-checks-before-free-in-drivers drivers/char/hvcs.c bos@19: --- a/drivers/char/hvcs.c~remove-redundant-null-checks-before-free-in-drivers bos@19: +++ a/drivers/char/hvcs.c bos@19: @@ -1320,11 +1320,12 @@ static struct tty_operations hvcs_ops = bos@19: static int hvcs_alloc_index_list(int n) bos@19: { bos@19: int i; bos@19: + bos@19: hvcs_index_list = kmalloc(n * sizeof(hvcs_index_count),GFP_KERNEL); bos@19: if (!hvcs_index_list) bos@19: return -ENOMEM; bos@19: hvcs_index_count = n; bos@19: - for(i = 0; i < hvcs_index_count; i++) bos@19: + for (i = 0; i < hvcs_index_count; i++) bos@19: hvcs_index_list[i] = -1; bos@19: return 0; bos@19: } bos@19: @@ -1332,11 +1333,9 @@ static int hvcs_alloc_index_list(int n) bos@19: static void hvcs_free_index_list(void) bos@19: { bos@19: /* Paranoia check to be thorough. */ bos@19: - if (hvcs_index_list) { bos@19: - kfree(hvcs_index_list); bos@19: - hvcs_index_list = NULL; bos@19: - hvcs_index_count = 0; bos@19: - } bos@19: + kfree(hvcs_index_list); bos@19: + hvcs_index_list = NULL; bos@19: + hvcs_index_count = 0; bos@19: } bos@19: bos@19: static int __init hvcs_module_init(void) bos@19: diff -puN drivers/message/fusion/mptfc.c~remove-redundant-null-checks-before-free-in-drivers drivers/message/fusion/mptfc.c bos@19: --- a/drivers/message/fusion/mptfc.c~remove-redundant-null-checks-before-free-in-drivers bos@19: +++ a/drivers/message/fusion/mptfc.c bos@19: @@ -305,10 +305,8 @@ mptfc_GetFcDevPage0(MPT_ADAPTER *ioc, in bos@19: } bos@19: bos@19: out: bos@19: - if (pp0_array) bos@19: - kfree(pp0_array); bos@19: - if (p0_array) bos@19: - kfree(p0_array); bos@19: + kfree(pp0_array); bos@19: + kfree(p0_array); bos@19: return rc; bos@19: } bos@19: bos@19: diff -puN drivers/message/fusion/mptsas.c~remove-redundant-null-checks-before-free-in-drivers drivers/message/fusion/mptsas.c bos@19: --- a/drivers/message/fusion/mptsas.c~remove-redundant-null-checks-before-free-in-drivers bos@19: +++ a/drivers/message/fusion/mptsas.c bos@19: @@ -1378,8 +1378,7 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc) bos@19: return 0; bos@19: bos@19: out_free_port_info: bos@19: - if (hba) bos@19: - kfree(hba); bos@19: + kfree(hba); bos@19: out: bos@19: return error; bos@19: } bos@19: diff -puN drivers/net/fs_enet/fs_enet-mii.c~remove-redundant-null-checks-before-free-in-drivers drivers/net/fs_enet/fs_enet-mii.c bos@19: --- a/drivers/net/fs_enet/fs_enet-mii.c~remove-redundant-null-checks-before-free-in-drivers bos@19: +++ a/drivers/net/fs_enet/fs_enet-mii.c bos@19: @@ -431,8 +431,7 @@ static struct fs_enet_mii_bus *create_bu bos@19: return bus; bos@19: bos@19: err: bos@19: - if (bus) bos@19: - kfree(bus); bos@19: + kfree(bus); bos@19: return ERR_PTR(ret); bos@19: } bos@19: bos@19: diff -puN drivers/net/wireless/ipw2200.c~remove-redundant-null-checks-before-free-in-drivers drivers/net/wireless/ipw2200.c bos@19: --- a/drivers/net/wireless/ipw2200.c~remove-redundant-null-checks-before-free-in-drivers bos@19: +++ a/drivers/net/wireless/ipw2200.c bos@19: @@ -1229,12 +1229,6 @@ static struct ipw_fw_error *ipw_alloc_er bos@19: return error; bos@19: } bos@19: bos@19: -static void ipw_free_error_log(struct ipw_fw_error *error) bos@19: -{ bos@19: - if (error) bos@19: - kfree(error); bos@19: -} bos@19: - bos@19: static ssize_t show_event_log(struct device *d, bos@19: struct device_attribute *attr, char *buf) bos@19: { bos@19: @@ -1296,10 +1290,9 @@ static ssize_t clear_error(struct device bos@19: const char *buf, size_t count) bos@19: { bos@19: struct ipw_priv *priv = dev_get_drvdata(d); bos@19: - if (priv->error) { bos@19: - ipw_free_error_log(priv->error); bos@19: - priv->error = NULL; bos@19: - } bos@19: + bos@19: + kfree(priv->error); bos@19: + priv->error = NULL; bos@19: return count; bos@19: } bos@19: bos@19: @@ -1970,8 +1963,7 @@ static void ipw_irq_tasklet(struct ipw_p bos@19: struct ipw_fw_error *error = bos@19: ipw_alloc_error_log(priv); bos@19: ipw_dump_error_log(priv, error); bos@19: - if (error) bos@19: - ipw_free_error_log(error); bos@19: + kfree(error); bos@19: } bos@19: #endif bos@19: } else { bos@19: @@ -11693,10 +11685,8 @@ static void ipw_pci_remove(struct pci_de bos@19: } bos@19: } bos@19: bos@19: - if (priv->error) { bos@19: - ipw_free_error_log(priv->error); bos@19: - priv->error = NULL; bos@19: - } bos@19: + kfree(priv->error); bos@19: + priv->error = NULL; bos@19: bos@19: #ifdef CONFIG_IPW2200_PROMISCUOUS bos@19: ipw_prom_free(priv); bos@19: diff -puN drivers/scsi/libata-scsi.c~remove-redundant-null-checks-before-free-in-drivers drivers/scsi/libata-scsi.c bos@19: --- a/drivers/scsi/libata-scsi.c~remove-redundant-null-checks-before-free-in-drivers bos@19: +++ a/drivers/scsi/libata-scsi.c bos@19: @@ -222,9 +222,7 @@ int ata_cmd_ioctl(struct scsi_device *sc bos@19: && copy_to_user(arg + sizeof(args), argbuf, argsize)) bos@19: rc = -EFAULT; bos@19: error: bos@19: - if (argbuf) bos@19: - kfree(argbuf); bos@19: - bos@19: + kfree(argbuf); bos@19: return rc; bos@19: } bos@19: bos@19: diff -puN drivers/video/au1100fb.c~remove-redundant-null-checks-before-free-in-drivers drivers/video/au1100fb.c bos@19: --- a/drivers/video/au1100fb.c~remove-redundant-null-checks-before-free-in-drivers bos@19: +++ a/drivers/video/au1100fb.c bos@19: @@ -743,8 +743,7 @@ void __exit au1100fb_cleanup(void) bos@19: { bos@19: driver_unregister(&au1100fb_driver); bos@19: bos@19: - if (drv_info.opt_mode) bos@19: - kfree(drv_info.opt_mode); bos@19: + kfree(drv_info.opt_mode); bos@19: } bos@19: bos@19: module_init(au1100fb_init); bos@19: _