mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 19:51:31 -04:00
Fix invalid access errors in blk_lookup_devt
Commit 30f2f0eb4b ("block: do_mounts -
accept root=<non-existant partition>") extended blk_lookup_devt() to be
able to look up partitions that had not yet been registered, but in the
process made the assumption that the '&block_class.devices' list only
contains disk devices and that you can do 'dev_to_disk(dev)' on them.
That isn't actually true. The block_class device list also contains the
partitions we've discovered so far, and you can't just do a
'dev_to_disk()' on those.
So make sure to only work on devices that block/genhd.c has registered
itself, something we can test by checking the 'dev->type' member. This
makes the loop in blk_lookup_devt() match the other such loops in this
file.
[ We may want to do an alternate version that knows to handle _either_
whole-disk devices or partitions, but for now this is the minimal fix
for a series of crashes reported by Mariusz Kozlowski in
http://lkml.org/lkml/2008/5/25/25
and Ingo in
http://lkml.org/lkml/2008/6/9/39 ]
Reported-by: Mariusz Kozlowski <[email protected]>
Reported-by: Ingo Molnar <[email protected]>
Cc: Neil Brown <[email protected]>
Cc: Joao Luis Meloni Assirati <[email protected]>
Acked-by: Kay Sievers <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
f751aa125d
commit
d5791d13b1
1 changed files with 2 additions and 0 deletions
|
|
@ -660,6 +660,8 @@ dev_t blk_lookup_devt(const char *name, int part)
|
|||
|
||||
mutex_lock(&block_class_lock);
|
||||
list_for_each_entry(dev, &block_class.devices, node) {
|
||||
if (dev->type != &disk_type)
|
||||
continue;
|
||||
if (strcmp(dev->bus_id, name) == 0) {
|
||||
struct gendisk *disk = dev_to_disk(dev);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue