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