Re: [linux-pm] [PATCH 2.6.25-rc1] cpufreq: fix cpufreq policy refcount imbalance

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Alan Stern
Date: Friday, February 15, 2008 - 8:52 am

On Fri, 15 Feb 2008, Yi Yang wrote:


Are you referring to this section of code (before the region affected 
by your patch)?

	if (!kobject_get(&data->kobj)) {
		spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
		cpufreq_debug_enable_ratelimit();
		unlock_policy_rwsem_write(cpu);
		return -EFAULT;
	}

Greg is correct that the kobject_get() here is useless and should be
removed.  kobject_get() never returns NULL unless its argument is NULL.  
Since &data->kobj can never be NULL, the "if" test will never fail.  
Hence there's no point in making the test at all.

The fact that a section of code has existed for a long time doesn't 
mean that it is right.  :-)

Furthermore, there's no reason to do the kobject_get().  Holding 2 
references to a kobject is no better than holding just 1 reference.  
Assuming you know that the kobject is still registered, then you also 
know that there is already a reference to it.  So you have no reason to 
take an additional reference.

Alan Stern

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH 2.6.24] x86: add sysfs interface for cpuid module, H. Peter Anvin, (Tue Jan 29, 11:09 pm)
Re: [PATCH 2.6.24] x86: add sysfs interface for cpuid module, H. Peter Anvin, (Wed Jan 30, 12:17 am)
Re: [PATCH 2.6.24] x86: add sysfs interface for cpuid module, H. Peter Anvin, (Wed Jan 30, 12:33 am)
Re: [linux-pm] [PATCH 2.6.25-rc1] cpufreq: fix cpufreq pol ..., Alan Stern, (Fri Feb 15, 8:52 am)