From: Greg KH <greg@kroah.com>
To: Andrew Zabolotny <zap@homelink.ru>
Cc: linux-kernel@vger.kernel.org
Subject: Re: class_device_find()
Date: Mon, 24 May 2004 09:46:31 -0700 [thread overview]
Message-ID: <20040524164630.GB1543@kroah.com> (raw)
In-Reply-To: <20040524103921.7957533a.zap@homelink.ru>
On Mon, May 24, 2004 at 10:39:21AM +0400, Andrew Zabolotny wrote:
> The class_device_find() function returns a pointer to a class_device, but the
> reference counter of that object is not incremented. This looks to me somewhat
> racy, unless there are some details I'm missing.
There were lots of problems with that function, and that's one reason
it's not in the kernel tree :)
> Because in the first case if class_device_get succeeds, but class_id is empty,
> the kobject will remain in a referenced state.
Good catch. But your fix is not quite correct, we should call
class_device_put() on the class_dev variable before returning -EINVAL
instead.
> I know patches are preferred, but our CVS is down right now and I don't have
> an older copy of class.c.
Patches are preferred.
> And yet one more comment. What is the purpose of class_device_get at the
> beginning and class_device_put at the end of the above function? I think if
> someone calls class_device_rename, then it already holds a reference to the
> class_device, so it can't go away while class_rename() is doing its work. And
> if the caller *doesn't* hold a lock on it, it is simply wrong code since the
> device may easily go away before class_rename() gets the lock.
We are just being safe.
thanks,
greg k-h
next prev parent reply other threads:[~2004-05-24 16:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20040523002309.2ec5965e.zap@homelink.ru>
[not found] ` <20040524051303.GC27371@kroah.com>
2004-05-24 6:39 ` class_device_find() Andrew Zabolotny
2004-05-24 16:46 ` Greg KH [this message]
2004-05-24 22:08 ` class_device_find() Andrew Zabolotny
2004-05-24 23:39 ` class_device_find() Greg KH
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=20040524164630.GB1543@kroah.com \
--to=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=zap@homelink.ru \
/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
all inboxes | Powered by JetHome®