From: NeilBrown Date: Wed, 16 Feb 2011 02:58:51 +0000 (+1100) Subject: md: correctly handle probe of an 'mdp' device. X-Git-Tag: firefly_0821_release~10186^2~391 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=62ead775d1932164b7113618800d87aed9fa0ac5;p=firefly-linux-kernel-4.4.55.git md: correctly handle probe of an 'mdp' device. commit 8f5f02c460b7ca74ce55ce126ce0c1e58a3f923d upstream. 'mdp' devices are md devices with preallocated device numbers for partitions. As such it is possible to mknod and open a partition before opening the whole device. this causes md_probe() to be called with a device number of a partition, which in-turn calls mddev_find with such a number. However mddev_find expects the number of a 'whole device' and does the wrong thing with partition numbers. So add code to mddev_find to remove the 'partition' part of a device number and just work with the 'whole device'. This patch addresses https://bugzilla.kernel.org/show_bug.cgi?id=28652 Reported-by: hkmaly@bigfoot.com Signed-off-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/md/md.c b/drivers/md/md.c index 68bfb68af5ad..697a2c7bff2c 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -305,6 +305,9 @@ static mddev_t * mddev_find(dev_t unit) { mddev_t *mddev, *new = NULL; + if (unit && MAJOR(unit) != MD_MAJOR) + unit &= ~((1<