From: "Nikita V. Youshchenko" <yoush@cs.msu.su>
To: linux-kernel@vger.kernel.org
Cc: Alexander Kaliadin <akaliadin@libertesoft.co.uk>
Subject: Possible bug in device_find() or in bus_add_device()
Date: Tue, 24 May 2005 01:09:18 +0400 [thread overview]
Message-ID: <200505240109.25710@sercond.localdomain> (raw)
[-- Attachment #1: Type: text/plain, Size: 1623 bytes --]
[2Alexander: the memory breakage I mentioned looks to be actually not a
memory breakage, but a bug in linux device model code. So I'm reporting it
to kernel mailing list]
Hello.
While developing a driver for an embedded system, I am getting crashes in
calls to device_find().
I tried to find out what is going on, and found the following.
Device seems to be added it's bus'es device list in bus_add_device() by the
following statement:
list_add_tail(&dev->bus_list, &dev->bus->devices.list);
So struct device object gets linked to bus->devices.list using it's
bus_list field.
However, device_find() calls kset_find_obj(&bus->devices, name), which in
turn dereferences bus->devices in the following statement:
list_for_each(entry,&kset->list) {
struct kobject * k = to_kobj(entry);
...
where kset->list is the above bus->devices.list, and to_kobj is defined as
container_of(entry,struct kobject,entry)
So it assumes that objects are linked to bus->devices.list using
kobject::entry field. But actually struct device objects are linked to
bus->devices.list using their bus_list field, not kobj.entry field!
So code in kset_find_obj() gets an invalid pointer to kobj, which leads to
a crash.
Looks like a bug.
The above code snippets all exist in (currently latest) 2.6.12-pre4 kernel
tree from kernel.org.
I'm not familiar with linux device model. Could someone please help to find
the best way to fix this (other than not using device_find() at all)?
Nikita Youshchenko
P.S.
Please CC replies to my e-mail address, yoush@cs.msu.su
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
reply other threads:[~2005-05-23 21:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200505240109.25710@sercond.localdomain \
--to=yoush@cs.msu.su \
--cc=akaliadin@libertesoft.co.uk \
--cc=linux-kernel@vger.kernel.org \
/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®