Checking a pointer for NULL before calling kfree() on it is redundant,
kfree() deals with NULL pointers just fine.
This patch removes such checks from files in arch/i386/

Since this is a fairly trivial change (and the same change made
everywhere) I've just made a single patch for all four files and CC all
authors/maintainers of those files I could find for comments. If spliting
this into one patch pr file is prefered, then I can easily do that as
well.

These are the files being modified :
        arch/i386/kernel/cpu/cpufreq/powernow-k7.c
        arch/i386/kernel/cpu/intel_cacheinfo.c
        arch/i386/kernel/cpu/mtrr/generic.c
        arch/i386/kernel/io_apic.c
        
(please CC me on replies to lists other than linux-kernel)


Signed-off-by: Jesper Juhl <[EMAIL PROTECTED]>

--- linux-2.6.11-mm4-orig/arch/i386/kernel/cpu/cpufreq/powernow-k7.c    
2005-03-16 15:45:02.000000000 +0100
+++ linux-2.6.11-mm4/arch/i386/kernel/cpu/cpufreq/powernow-k7.c 2005-03-20 
00:41:27.000000000 +0100
@@ -643,9 +643,7 @@ static int powernow_cpu_exit (struct cpu
        }
 #endif
 
-       if (powernow_table)
-               kfree(powernow_table);
-
+       kfree(powernow_table);
        return 0;
 }
 
--- linux-2.6.11-mm4-orig/arch/i386/kernel/cpu/intel_cacheinfo.c        
2005-03-16 15:45:02.000000000 +0100
+++ linux-2.6.11-mm4/arch/i386/kernel/cpu/intel_cacheinfo.c     2005-03-20 
00:43:21.000000000 +0100
@@ -491,12 +491,9 @@ static int cpuid4_cache_sysfs_init(unsig
 
 err_out:
        for (i = 0; i < NR_CPUS; i++) {
-               if(cpuid4_info[i])
-                       kfree(cpuid4_info[i]);
-               if(cache_kobject[i])
-                       kfree(cache_kobject[i]);
-               if(index_kobject[i])
-                       kfree(index_kobject[i]);
+               kfree(cpuid4_info[i]);
+               kfree(cache_kobject[i]);
+               kfree(index_kobject[i]);
 
                cpuid4_info[i] = NULL;
                cache_kobject[i] = NULL;
@@ -508,12 +505,9 @@ err_out:
 
 static int cpuid4_cache_sysfs_exit(unsigned int i)
 {
-       if(cpuid4_info[i])
-               kfree(cpuid4_info[i]);
-       if(cache_kobject[i])
-               kfree(cache_kobject[i]);
-       if(index_kobject[i])
-               kfree(index_kobject[i]);
+       kfree(cpuid4_info[i]);
+       kfree(cache_kobject[i]);
+       kfree(index_kobject[i]);
 
        cpuid4_info[i] = NULL;
        cache_kobject[i] = NULL;
--- linux-2.6.11-mm4-orig/arch/i386/kernel/cpu/mtrr/generic.c   2005-03-16 
15:45:02.000000000 +0100
+++ linux-2.6.11-mm4/arch/i386/kernel/cpu/mtrr/generic.c        2005-03-20 
00:43:39.000000000 +0100
@@ -70,8 +70,7 @@ void __init get_mtrr_state(void)
 /*  Free resources associated with a struct mtrr_state  */
 void __init finalize_mtrr_state(void)
 {
-       if (mtrr_state.var_ranges)
-               kfree(mtrr_state.var_ranges);
+       kfree(mtrr_state.var_ranges);
        mtrr_state.var_ranges = NULL;
 }
 
--- linux-2.6.11-mm4-orig/arch/i386/kernel/io_apic.c    2005-03-16 
15:45:02.000000000 +0100
+++ linux-2.6.11-mm4/arch/i386/kernel/io_apic.c 2005-03-20 00:44:47.000000000 
+0100
@@ -632,10 +632,8 @@ static int __init balanced_irq_init(void
                printk(KERN_ERR "balanced_irq_init: failed to spawn 
balanced_irq");
 failed:
        for (i = 0; i < NR_CPUS; i++) {
-               if(irq_cpu_data[i].irq_delta)
-                       kfree(irq_cpu_data[i].irq_delta);
-               if(irq_cpu_data[i].last_irq)
-                       kfree(irq_cpu_data[i].last_irq);
+               kfree(irq_cpu_data[i].irq_delta);
+               kfree(irq_cpu_data[i].last_irq);
        }
        return 0;
 }


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to