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