diff options
author | Chengguang Xu <cgxu519@gmx.com> | 2019-02-15 20:27:11 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-06-11 12:24:03 +0200 |
commit | cb7872f128359b7ef982780703411eb2a68a2390 (patch) | |
tree | 07637f470136a271090b1b7fb320ce48095c5e95 | |
parent | 5680f59f0f151ff22faa1351f15f0d0351266e71 (diff) | |
download | linux-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>
-rw-r--r-- | fs/char_dev.c | 6 |
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; |