Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

char: misc: Does not request module for miscdevice with dynamic minor

misc_open() may request module for miscdevice with dynamic minor, which
is meaningless since:

- The dynamic minor allocated is unknown in advance without registering
miscdevice firstly.
- Macro MODULE_ALIAS_MISCDEV() is not applicable for dynamic minor.

Fix by only requesting module for miscdevice with fixed minor.

Acked-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
Signed-off-by: Zijun Hu <zijun.hu@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250714-rfc_miscdev-v6-6-2ed949665bde@oss.qualcomm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Zijun Hu and committed by
Greg Kroah-Hartman
1ba0fb42 52e2bb5f

+5 -3
+5 -3
drivers/char/misc.c
··· 132 132 break; 133 133 } 134 134 135 - if (!new_fops) { 135 + /* Only request module for fixed minor code */ 136 + if (!new_fops && minor < MISC_DYNAMIC_MINOR) { 136 137 mutex_unlock(&misc_mtx); 137 138 request_module("char-major-%d-%d", MISC_MAJOR, minor); 138 139 mutex_lock(&misc_mtx); ··· 145 144 new_fops = fops_get(iter->fops); 146 145 break; 147 146 } 148 - if (!new_fops) 149 - goto fail; 150 147 } 148 + 149 + if (!new_fops) 150 + goto fail; 151 151 152 152 /* 153 153 * Place the miscdevice in the file's