summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChengguang Xu <cgxu519@gmx.com>2019-02-15 20:27:11 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-06-11 12:24:03 +0200
commitcb7872f128359b7ef982780703411eb2a68a2390 (patch)
tree07637f470136a271090b1b7fb320ce48095c5e95 /fs
parent5680f59f0f151ff22faa1351f15f0d0351266e71 (diff)
downloadlinux-stable-cb7872f128359b7ef982780703411eb2a68a2390.tar.gz
linux-stable-cb7872f128359b7ef982780703411eb2a68a2390.tar.bz2
linux-stable-cb7872f128359b7ef982780703411eb2a68a2390.zip
chardev: add additional check for minor range overlap
[ Upstream commit de36e16d1557a0b6eb328bc3516359a12ba5c25c ] Current overlap checking cannot correctly handle a case which is baseminor < existing baseminor && baseminor + minorct > existing baseminor + minorct. Signed-off-by: Chengguang Xu <cgxu519@gmx.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/char_dev.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/char_dev.c b/fs/char_dev.c
index 24b142569ca9..d0655ca89481 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -130,6 +130,12 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor,
ret = -EBUSY;
goto out;
}
+
+ if (new_min < old_min && new_max > old_max) {
+ ret = -EBUSY;
+ goto out;
+ }
+
}
cd->next = *cp;