mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
52e2bb5ff0
commit
1ba0fb42aa
@@ -132,7 +132,8 @@ static int misc_open(struct inode *inode, struct file *file)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!new_fops) {
|
/* Only request module for fixed minor code */
|
||||||
|
if (!new_fops && minor < MISC_DYNAMIC_MINOR) {
|
||||||
mutex_unlock(&misc_mtx);
|
mutex_unlock(&misc_mtx);
|
||||||
request_module("char-major-%d-%d", MISC_MAJOR, minor);
|
request_module("char-major-%d-%d", MISC_MAJOR, minor);
|
||||||
mutex_lock(&misc_mtx);
|
mutex_lock(&misc_mtx);
|
||||||
@@ -144,10 +145,11 @@ static int misc_open(struct inode *inode, struct file *file)
|
|||||||
new_fops = fops_get(iter->fops);
|
new_fops = fops_get(iter->fops);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!new_fops)
|
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!new_fops)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Place the miscdevice in the file's
|
* Place the miscdevice in the file's
|
||||||
* private_data so it can be used by the
|
* private_data so it can be used by the
|
||||||
|
|||||||
Reference in New Issue
Block a user