From: Greg KH <gregkh@suse.de>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Yi Yang <yi.y.yang@intel.com>,
akpm@linux-foundation.org, davej@codemonkey.org.uk,
cpufreq@lists.linux.org.uk, linux-kernel@vger.kernel.org,
linux-acpi@vger.kernel.org, mingo@elte.hu,
torvalds@linux-foundation.org,
linux-pm@lists.linux-foundation.org
Subject: Re: [linux-pm] [PATCH 2.6.25-rc1] cpufreq: fix cpufreq policy refcount imbalance
Date: Fri, 15 Feb 2008 10:24:21 -0800 [thread overview]
Message-ID: <20080215182421.GA5593@suse.de> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0802151043230.3423-100000@iolanthe.rowland.org>
On Fri, Feb 15, 2008 at 10:52:51AM -0500, Alan Stern wrote:
> On Fri, 15 Feb 2008, Yi Yang wrote:
>
> > This patch adds kobject_put to balance refcount. I noticed Greg suggests
> > it will fix a power-off issue to remove kobject_get statement block, but i
> > think that isn't the best way because those code block has existed very long
> > and it is helpful because the successive statements are invoking relevant
> > data.
>
> 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.
There's the additional problem that this second reference count is never
dropped, causing a bug :)
thanks,
greg k-h
next prev parent reply other threads:[~2008-02-15 18:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1199441414.19185.9.camel@yangyi-dev.bj.intel.com>
[not found] ` <1201043126.3861.5.camel@yangyi-dev.bj.intel.com>
2008-02-14 23:44 ` [PATCH 2.6.25-rc1] cpufreq: fix cpufreq policy refcount imbalance Yi Yang
2008-02-14 23:48 ` Yi Yang
2008-02-15 15:52 ` [linux-pm] " Alan Stern
2008-02-15 18:24 ` Greg KH [this message]
2008-02-15 21:01 ` Greg KH
2008-02-25 0:46 ` [PATCH 2.6.25-rc3] cpuidle: fix cpuidle time and usage overflow Yi Yang
2008-02-25 10:15 ` Ingo Molnar
2008-02-25 1:10 ` Yi Yang
2008-03-26 4:46 ` Len Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080215182421.GA5593@suse.de \
--to=gregkh@suse.de \
--cc=akpm@linux-foundation.org \
--cc=cpufreq@lists.linux.org.uk \
--cc=davej@codemonkey.org.uk \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=mingo@elte.hu \
--cc=stern@rowland.harvard.edu \
--cc=torvalds@linux-foundation.org \
--cc=yi.y.yang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox