kdev_t: mask mi with MINORMASK in MKDEV macro
In MKDEV macro, if mi is larger than MINORMASK, the major will be affected by mi. For example, set dev = MKDEV(2, (1U << MINORBITS)), then MAJOR(dev) will be equal to 3, incorrectly.
Here, we mask mi with MINORMASK in MKDEV macro.
Signed-off-by Zhiqiang Liu <[email protected]>
--- include/linux/kdev_t.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/kdev_t.h +1 -1
@@ -9,7 +9,7 @@#define MAJOR (dev) ((unsigned int) ((dev) >> MINORBITS))#define MINOR (dev) ((unsigned int) ((dev) & MINORMASK)) -#define MKDEV (ma,mi) (((ma) << MINORBITS) | (mi)) +#define MKDEV (ma, mi) (((ma) << MINORBITS) | ((mi) & MINORMASK))#define print_dev_t (buffer, dev) \ sprintf((buffer), "%u:%u\n", MAJOR(dev), MINOR(dev))
Signature · 1 line
2.19.1