Big kfree NULL check cleanup - arch
Subsystems (7)
PATCH 11/14 Big kfree NULL check cleanup - arch
This is the arch/ part of the big kfree cleanup patch.
Remove pointless checks for NULL prior to calling kfree() in arch/.
Sorry about the long Cc: list, but I wanted to make sure I included everyone who's code I've changed with this patch.
---
Please see the initial announcement mail on LKML with subject "[PATCH 00/14] Big kfree NULL check cleanup"
for additional details.
arch/arm/mach-integrator/impd1.c | 3 +-- arch/cris/arch-v32/drivers/cryptocop.c | 14 +++++++------- arch/ia64/kernel/perfmon.c | 2 +- arch/mips/au1000/common/dbdma.c | 3 +-- arch/mips/au1000/common/usbdev.c | 6 ++---- arch/mips/kernel/irixelf.c | 5 ++--- arch/parisc/kernel/ioctl32.c | 32 +++++++++----------------------- 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/drivers/ubd_kern.c | 24 +++++++++--------------- arch/um/kernel/sigio_user.c | 2 +- 18 files changed, 49 insertions(+), 89 deletions(-)
arch/um/drivers/ubd_kern.c +9 -15
@@ -534,38 +534,32 @@ static irqreturn_t ubd_intr(int irq, voi aio = container_of(reply.data, struct ubd_aio, aio); n = reply.err; -if (n ==0 ){ +if (n ==0 ){ req = aio->req; req->nr_sectors -= aio->len >>9 ; -if ((aio->bitmap !=NULL ) && +if ((aio->bitmap !=NULL ) && (atomic_dec_and_test (&aio->bitmap->count))){ aio->aio = aio->bitmap->aio; aio->len =0 ;kfree (aio->bitmap); aio->bitmap =NULL ;submit_aio (&aio->aio); - } -else { + }else {if ((req->nr_sectors ==0 ) && (aio->bitmap ==NULL )){int len = req->hard_nr_sectors <<9 ;ubd_finish (req, len); } - -if (aio->bitmap_buf !=NULL ) -kfree (aio->bitmap_buf); +kfree (aio->bitmap_buf);kfree (aio); } + }else if (n <0 ) { +ubd_finish (aio->req, n); +kfree (aio->bitmap); +kfree (aio->bitmap_buf); +kfree (aio); } -else if (n <0 ){ -ubd_finish (aio->req, n); -if (aio->bitmap !=NULL ) -kfree (aio->bitmap); -if (aio->bitmap_buf !=NULL ) -kfree (aio->bitmap_buf); -kfree (aio); - } }reactivate_fd (fd,UBD_IRQ );
arch/um/kernel/sigio_user.c +1 -1
@@ -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" );
arch/arm/mach-integrator/impd1.c +1 -2
@@ -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;
arch/ppc/syslib/prom.c +2 -4
@@ -1335,10 +1335,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);
arch/ppc/8xx_io/cs4218_tdm.c +1 -2
@@ -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 */
arch/cris/arch-v32/drivers/cryptocop.c +7 -7
@@ -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(strucput_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 ());
arch/ia64/kernel/perfmon.c +1 -1
@@ -4939,7 +4939,7 @@ abort_locked:if (call_made &&PFM_CMD_RW_ARG (cmd) &©_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));
arch/mips/au1000/common/dbdma.c +1 -2
@@ -738,8 +738,7 @@ au1xxx_dbdma_chan_free(u32 chanid)au1xxx_dbdma_stop (chanid); -if (ctp->chan_desc_base !=NULL ) -kfree (ctp->chan_desc_base); +kfree (ctp->chan_desc_base); stp->dev_flags &= ~DEV_FLAGS_INUSE ; dtp->dev_flags &= ~DEV_FLAGS_INUSE ;
arch/mips/au1000/common/usbdev.c +2 -4
@@ -1072,8 +1072,7 @@ dma_done_ep0_intr(int irq, void *dev_id,clear_dma_done1 (ep0->indma); pkt =send_packet_complete (ep0); -if (pkt) -kfree (pkt); +kfree (pkt); }/*
@@ -1302,8 +1301,7 @@ usbdev_exit(void)endpoint_flush (ep); } -if (usbdev.full_conf_desc) -kfree (usbdev.full_conf_desc); +kfree (usbdev.full_conf_desc); }int
arch/mips/kernel/irixelf.c +2 -3
@@ -782,11 +782,10 @@ out_free_dentry:allow_write_access (interpreter);fput (interpreter); out_free_interp: -if (elf_interpreter) -kfree (elf_interpreter); +kfree (elf_interpreter); out_free_file: out_free_ph: -kfree (elf_phdata); +kfree (elf_phdata); goto out; }
arch/s390/mm/extmem.c +4 -4
@@ -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 dlist_del (&seg->list);dcss_diag (DCSS_PURGESEG , seg->dcss_name, &dummy, &dummy); -kfree (seg); +kfree (seg); out_unlock:spin_unlock (&dcss_lock);return rc;
arch/ppc64/kernel/lparcfg.c +1 -3
@@ -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); } }
arch/ppc64/kernel/scanlog.c +1 -2
@@ -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); } }
arch/ppc64/kernel/pSeries_reconfig.c +2 -4
@@ -286,10 +286,8 @@ static struct property *new_property(conreturn new; cleanup: -if (new->name) -kfree (new->name); -if (new->value) -kfree (new->value); +kfree (new->name); +kfree (new->value);kfree (new);return NULL ; }
arch/ppc64/kernel/rtas_flash.c +1 -2
@@ -565,8 +565,7 @@ static int validate_flash_release(structstatic 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); }
arch/sparc64/kernel/us3_cpufreq.c +2 -5
@@ -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);
arch/sparc64/kernel/us2e_cpufreq.c +2 -5
@@ -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);
arch/parisc/kernel/ioctl32.c +9 -23
@@ -104,12 +104,9 @@ static int drm32_version(unsigned int fd } out: -if (kversion.name) -kfree (kversion.name); -if (kversion.date) -kfree (kversion.date); -if (kversion.desc) -kfree (kversion.desc); +kfree (kversion.name); +kfree (kversion.date); +kfree (kversion.desc);return ret; }
@@ -166,9 +163,7 @@ static int drm32_getsetunique(unsigned i ret = -EFAULT ; } -if (karg.unique !=NULL ) -kfree (karg.unique); - +kfree (karg.unique);return ret; }
@@ -265,7 +260,6 @@ static int drm32_info_bufs(unsigned int }kfree (karg.list); -return ret; }
@@ -305,7 +299,6 @@ static int drm32_free_bufs(unsigned int out:kfree (karg.list); -return ret; }
@@ -494,15 +487,10 @@ static int drm32_dma(unsigned int fd, un } out: -if (karg.send_indices) -kfree (karg.send_indices); -if (karg.send_sizes) -kfree (karg.send_sizes); -if (karg.request_indices) -kfree (karg.request_indices); -if (karg.request_sizes) -kfree (karg.request_sizes); - +kfree (karg.send_indices); +kfree (karg.send_sizes); +kfree (karg.request_indices); +kfree (karg.request_sizes);return ret; }
@@ -555,9 +543,7 @@ static int drm32_res_ctx(unsigned int fd ret = -EFAULT ; } -if (karg.contexts) -kfree (karg.contexts); - +kfree (karg.contexts);return ret; }
Quoted 6 lines · Jesper Juhl
This is the
arch/part of the big kfree cleanup patch. Remove pointless checks for NULL prior to callingkfree()inarch/.Signed-off-by Jesper Juhl <[email protected]>arch/parisc/kernel/ioctl32.c | 32 +++++++++-----------------------
Looks good to me.
thanks,
grant
Quoted 1 line · Jesper Juhl
This is the
arch/part of the big kfree cleanup patch.
Ignore the parisc part; it conflicts with simply deleting that code (patch from hch).
Quoted 6 lines · Matthew Wilcox
Quoted 1 line · Jesper Juhl
This is the
arch/part of the big kfree cleanup patch.Ignore the parisc part; it conflicts with simply deleting that code (patch from hch).
Attached is a patch to revert that.
--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
arch/parisc/kernel/ioctl32.c renamed from arch/parisc/kernel/ioctl32.c.a +23 -9
@@ -104,9 +104,12 @@ static int drm32_version(unsigned int fd } out: -kfree (kversion.name); -kfree (kversion.date); -kfree (kversion.desc); +if (kversion.name) +kfree (kversion.name); +if (kversion.date) +kfree (kversion.date); +if (kversion.desc) +kfree (kversion.desc);return ret; }
@@ -163,7 +166,9 @@ static int drm32_getsetunique(unsigned i ret = -EFAULT ; } -kfree (karg.unique); +if (karg.unique !=NULL ) +kfree (karg.unique); +return ret; }
@@ -260,6 +265,7 @@ static int drm32_info_bufs(unsigned int }kfree (karg.list); +return ret; }
@@ -299,6 +305,7 @@ static int drm32_free_bufs(unsigned int out:kfree (karg.list); +return ret; }
@@ -487,10 +494,15 @@ static int drm32_dma(unsigned int fd, un } out: -kfree (karg.send_indices); -kfree (karg.send_sizes); -kfree (karg.request_indices); -kfree (karg.request_sizes); +if (karg.send_indices) +kfree (karg.send_indices); +if (karg.send_sizes) +kfree (karg.send_sizes); +if (karg.request_indices) +kfree (karg.request_indices); +if (karg.request_sizes) +kfree (karg.request_sizes); +return ret; }
@@ -543,7 +555,9 @@ static int drm32_res_ctx(unsigned int fd ret = -EFAULT ; } -kfree (karg.contexts); +if (karg.contexts) +kfree (karg.contexts); +return ret; }