[PATCH 0/1] misc: Prevent double registration and deregistration of miscdevice
Greg Kroah-Hartman
gregkh at linuxfoundation.org
Mon Aug 25 13:27:28 PDT 2025
On Mon, Aug 25, 2025 at 04:45:46PM +0800, xion.wang at mediatek.com wrote:
> From: Xion Wang <xion.wang at mediatek.com>
>
> Dear maintainers,
>
> I am submitting a patch to improve the robustness of the misc device subsystem in the Linux kernel.
>
> In the current implementation, repeated calls to misc_register() or misc_deregister() on the same miscdevice instance may result in corruption of the misc_list or kernel crash due to multiple INIT_LIST_HEAD or list_del operations on the same list node.
Don't do that then :)
Seriously, what in-tree driver does that?
> This patch introduces additional checks in both misc_register() and misc_deregister() to prevent double registration and double deregistration. By using misc->this_device as a status flag, the driver can safely determine whether the device has already been registered or deregistered, and avoid performing dangerous operations on the misc_list.
>
> With these changes, the misc device subsystem becomes more stable and reliable, reducing the risks of list corruption and improving overall system safety.
But again, what driver is doing this? Why is this really needed?
thanks,
greg k-h
More information about the Linux-mediatek
mailing list