From: Jesper Juhl This is the arch/ part of the big kfree cleanup patch. Remove pointless checks for NULL prior to calling kfree() in arch/. Signed-off-by: Jesper Juhl Acked-by: Grant Grundler Signed-off-by: Andrew Morton --- arch/arm/mach-integrator/impd1.c | 3 +-- arch/cris/arch-v32/drivers/cryptocop.c | 14 +++++++------- arch/ia64/kernel/perfmon.c | 2 +- arch/ppc/8xx_io/cs4218_tdm.c | 3 +-- arch/ppc/syslib/prom.c | 6 ++---- arch/ppc64/kernel/lparcfg.c | 4 +--- arch/ppc64/kernel/pSeries_reconfig.c | 6 ++---- arch/ppc64/kernel/rtas_flash.c | 3 +-- arch/ppc64/kernel/scanlog.c | 3 +-- arch/s390/mm/extmem.c | 8 ++++---- arch/sparc64/kernel/us2e_cpufreq.c | 7 ++----- arch/sparc64/kernel/us3_cpufreq.c | 7 ++----- arch/um/kernel/sigio_user.c | 2 +- 13 files changed, 26 insertions(+), 42 deletions(-) diff -puN arch/arm/mach-integrator/impd1.c~kfree-cleanup-arch arch/arm/mach-integrator/impd1.c --- devel/arch/arm/mach-integrator/impd1.c~kfree-cleanup-arch 2005-10-14 15:18:54.000000000 -0700 +++ devel-akpm/arch/arm/mach-integrator/impd1.c 2005-10-14 15:18:54.000000000 -0700 @@ -420,8 +420,7 @@ static int impd1_probe(struct lm_device free_impd1: if (impd1 && impd1->base) iounmap(impd1->base); - if (impd1) - kfree(impd1); + kfree(impd1); release_lm: release_mem_region(dev->resource.start, SZ_4K); return ret; diff -puN arch/cris/arch-v32/drivers/cryptocop.c~kfree-cleanup-arch arch/cris/arch-v32/drivers/cryptocop.c --- devel/arch/cris/arch-v32/drivers/cryptocop.c~kfree-cleanup-arch 2005-10-14 15:18:54.000000000 -0700 +++ devel-akpm/arch/cris/arch-v32/drivers/cryptocop.c 2005-10-14 15:18:54.000000000 -0700 @@ -277,7 +277,7 @@ struct file_operations cryptocop_fops = static void free_cdesc(struct cryptocop_dma_desc *cdesc) { DEBUG(printk("free_cdesc: cdesc 0x%p, from_pool=%d\n", cdesc, cdesc->from_pool)); - if (cdesc->free_buf) kfree(cdesc->free_buf); + kfree(cdesc->free_buf); if (cdesc->from_pool) { unsigned long int flags; @@ -2950,15 +2950,15 @@ static int cryptocop_ioctl_process(struc put_page(outpages[i]); } - if (digest_result) kfree(digest_result); - if (inpages) kfree(inpages); - if (outpages) kfree(outpages); + kfree(digest_result); + kfree(inpages); + kfree(outpages); if (cop){ - if (cop->tfrm_op.indata) kfree(cop->tfrm_op.indata); - if (cop->tfrm_op.outdata) kfree(cop->tfrm_op.outdata); + kfree(cop->tfrm_op.indata); + kfree(cop->tfrm_op.outdata); kfree(cop); } - if (jc) kfree(jc); + kfree(jc); DEBUG(print_lock_status()); diff -puN arch/ia64/kernel/perfmon.c~kfree-cleanup-arch arch/ia64/kernel/perfmon.c --- devel/arch/ia64/kernel/perfmon.c~kfree-cleanup-arch 2005-10-14 15:18:54.000000000 -0700 +++ devel-akpm/arch/ia64/kernel/perfmon.c 2005-10-14 15:18:54.000000000 -0700 @@ -4940,7 +4940,7 @@ abort_locked: if (call_made && PFM_CMD_RW_ARG(cmd) && copy_to_user(arg, args_k, base_sz*count)) ret = -EFAULT; error_args: - if (args_k) kfree(args_k); + kfree(args_k); DPRINT(("cmd=%s ret=%ld\n", PFM_CMD_NAME(cmd), ret)); diff -puN arch/ppc64/kernel/lparcfg.c~kfree-cleanup-arch arch/ppc64/kernel/lparcfg.c --- devel/arch/ppc64/kernel/lparcfg.c~kfree-cleanup-arch 2005-10-14 15:18:54.000000000 -0700 +++ devel-akpm/arch/ppc64/kernel/lparcfg.c 2005-10-14 15:18:54.000000000 -0700 @@ -599,9 +599,7 @@ int __init lparcfg_init(void) void __exit lparcfg_cleanup(void) { if (proc_ppc64_lparcfg) { - if (proc_ppc64_lparcfg->data) { - kfree(proc_ppc64_lparcfg->data); - } + kfree(proc_ppc64_lparcfg->data); remove_proc_entry("lparcfg", proc_ppc64_lparcfg->parent); } } diff -puN arch/ppc64/kernel/pSeries_reconfig.c~kfree-cleanup-arch arch/ppc64/kernel/pSeries_reconfig.c --- devel/arch/ppc64/kernel/pSeries_reconfig.c~kfree-cleanup-arch 2005-10-14 15:18:54.000000000 -0700 +++ devel-akpm/arch/ppc64/kernel/pSeries_reconfig.c 2005-10-14 15:18:54.000000000 -0700 @@ -286,10 +286,8 @@ static struct property *new_property(con return new; cleanup: - if (new->name) - kfree(new->name); - if (new->value) - kfree(new->value); + kfree(new->name); + kfree(new->value); kfree(new); return NULL; } diff -puN arch/ppc64/kernel/rtas_flash.c~kfree-cleanup-arch arch/ppc64/kernel/rtas_flash.c --- devel/arch/ppc64/kernel/rtas_flash.c~kfree-cleanup-arch 2005-10-14 15:18:54.000000000 -0700 +++ devel-akpm/arch/ppc64/kernel/rtas_flash.c 2005-10-14 15:18:54.000000000 -0700 @@ -565,8 +565,7 @@ static int validate_flash_release(struct static void remove_flash_pde(struct proc_dir_entry *dp) { if (dp) { - if (dp->data != NULL) - kfree(dp->data); + kfree(dp->data); dp->owner = NULL; remove_proc_entry(dp->name, dp->parent); } diff -puN arch/ppc64/kernel/scanlog.c~kfree-cleanup-arch arch/ppc64/kernel/scanlog.c --- devel/arch/ppc64/kernel/scanlog.c~kfree-cleanup-arch 2005-10-14 15:18:54.000000000 -0700 +++ devel-akpm/arch/ppc64/kernel/scanlog.c 2005-10-14 15:18:54.000000000 -0700 @@ -225,8 +225,7 @@ int __init scanlog_init(void) void __exit scanlog_cleanup(void) { if (proc_ppc64_scan_log_dump) { - if (proc_ppc64_scan_log_dump->data) - kfree(proc_ppc64_scan_log_dump->data); + kfree(proc_ppc64_scan_log_dump->data); remove_proc_entry("scan-log-dump", proc_ppc64_scan_log_dump->parent); } } diff -puN arch/ppc/8xx_io/cs4218_tdm.c~kfree-cleanup-arch arch/ppc/8xx_io/cs4218_tdm.c --- devel/arch/ppc/8xx_io/cs4218_tdm.c~kfree-cleanup-arch 2005-10-14 15:18:54.000000000 -0700 +++ devel-akpm/arch/ppc/8xx_io/cs4218_tdm.c 2005-10-14 15:18:54.000000000 -0700 @@ -1013,8 +1013,7 @@ static void CS_IrqCleanup(void) */ cpm_free_handler(CPMVEC_SMC2); - if (beep_buf) - kfree(beep_buf); + kfree(beep_buf); kd_mksound = orig_mksound; } #endif /* MODULE */ diff -puN arch/ppc/syslib/prom.c~kfree-cleanup-arch arch/ppc/syslib/prom.c --- devel/arch/ppc/syslib/prom.c~kfree-cleanup-arch 2005-10-14 15:18:54.000000000 -0700 +++ devel-akpm/arch/ppc/syslib/prom.c 2005-10-14 15:18:54.000000000 -0700 @@ -1337,10 +1337,8 @@ release_OF_resource(struct device_node* if (!res) return -ENODEV; - if (res->name) { - kfree(res->name); - res->name = NULL; - } + kfree(res->name); + res->name = NULL; release_resource(res); kfree(res); diff -puN arch/s390/mm/extmem.c~kfree-cleanup-arch arch/s390/mm/extmem.c --- devel/arch/s390/mm/extmem.c~kfree-cleanup-arch 2005-10-14 15:18:54.000000000 -0700 +++ devel-akpm/arch/s390/mm/extmem.c 2005-10-14 15:18:54.000000000 -0700 @@ -234,8 +234,8 @@ query_segment_type (struct dcss_segment rc = 0; out_free: - if (qin) kfree(qin); - if (qout) kfree(qout); + kfree(qin); + kfree(qout); return rc; } @@ -394,7 +394,7 @@ __segment_load (char *name, int do_nonsh segtype_string[seg->vm_segtype]); goto out; out_free: - kfree (seg); + kfree(seg); out: return rc; } @@ -505,7 +505,7 @@ segment_modify_shared (char *name, int d list_del(&seg->list); dcss_diag(DCSS_PURGESEG, seg->dcss_name, &dummy, &dummy); - kfree (seg); + kfree(seg); out_unlock: spin_unlock(&dcss_lock); return rc; diff -puN arch/sparc64/kernel/us2e_cpufreq.c~kfree-cleanup-arch arch/sparc64/kernel/us2e_cpufreq.c --- devel/arch/sparc64/kernel/us2e_cpufreq.c~kfree-cleanup-arch 2005-10-14 15:18:54.000000000 -0700 +++ devel-akpm/arch/sparc64/kernel/us2e_cpufreq.c 2005-10-14 15:18:54.000000000 -0700 @@ -388,10 +388,8 @@ err_out: kfree(driver); cpufreq_us2e_driver = NULL; } - if (us2e_freq_table) { - kfree(us2e_freq_table); - us2e_freq_table = NULL; - } + kfree(us2e_freq_table); + us2e_freq_table = NULL; return ret; } @@ -402,7 +400,6 @@ static void __exit us2e_freq_exit(void) { if (cpufreq_us2e_driver) { cpufreq_unregister_driver(cpufreq_us2e_driver); - kfree(cpufreq_us2e_driver); cpufreq_us2e_driver = NULL; kfree(us2e_freq_table); diff -puN arch/sparc64/kernel/us3_cpufreq.c~kfree-cleanup-arch arch/sparc64/kernel/us3_cpufreq.c --- devel/arch/sparc64/kernel/us3_cpufreq.c~kfree-cleanup-arch 2005-10-14 15:18:54.000000000 -0700 +++ devel-akpm/arch/sparc64/kernel/us3_cpufreq.c 2005-10-14 15:18:54.000000000 -0700 @@ -249,10 +249,8 @@ err_out: kfree(driver); cpufreq_us3_driver = NULL; } - if (us3_freq_table) { - kfree(us3_freq_table); - us3_freq_table = NULL; - } + kfree(us3_freq_table); + us3_freq_table = NULL; return ret; } @@ -263,7 +261,6 @@ static void __exit us3_freq_exit(void) { if (cpufreq_us3_driver) { cpufreq_unregister_driver(cpufreq_us3_driver); - kfree(cpufreq_us3_driver); cpufreq_us3_driver = NULL; kfree(us3_freq_table); diff -puN arch/um/kernel/sigio_user.c~kfree-cleanup-arch arch/um/kernel/sigio_user.c --- devel/arch/um/kernel/sigio_user.c~kfree-cleanup-arch 2005-10-14 15:18:54.000000000 -0700 +++ devel-akpm/arch/um/kernel/sigio_user.c 2005-10-14 15:18:54.000000000 -0700 @@ -225,7 +225,7 @@ static int need_poll(int n) next_poll.used = n; return(0); } - if(next_poll.poll != NULL) kfree(next_poll.poll); + kfree(next_poll.poll); next_poll.poll = um_kmalloc_atomic(n * sizeof(struct pollfd)); if(next_poll.poll == NULL){ printk("need_poll : failed to allocate new pollfds\n"); _