Commit dd7937d3 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] 32-bit dev_t: md fallout

This fixes a NULL ptr dereference in md_probe() noted by Helge Hafting.

It even gets the things slightly better than they used to be, but
late-boot magic in md.c is certainly a mess.  Oh, well...

It's _ugly_.  md_probe() is misused there big way.  The minimal fix is
to revert the cleanup in md_probe() - replace

	int unit = *part;
with
	int unit = MINOR(dev);


However, that is crap solution.  The problem is that md_probe() is called
directly with bogus arguments - not only part is NULL (which triggers the
oops), but dev (which is supposed to be dev_t value) is actually mdidx(mddev).

Cleaner fix follows, but we really need to get the situation with gendisk
allocations into the sane shape there.  Sigh...
parent 83157abd
......@@ -1500,6 +1500,7 @@ static int do_md_run(mddev_t * mddev)
mdk_rdev_t *rdev;
struct gendisk *disk;
char b[BDEVNAME_SIZE];
int unit;
if (list_empty(&mddev->disks)) {
MD_BUG();
......@@ -1591,8 +1592,9 @@ static int do_md_run(mddev_t * mddev)
invalidate_bdev(rdev->bdev, 0);
}
md_probe(mdidx(mddev), NULL, NULL);
disk = disks[mdidx(mddev)];
unit = mdidx(mddev);
md_probe(0, &unit, NULL);
disk = disks[unit];
if (!disk)
return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment