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.

misc: remove ineffective WARN_ON() check from misc_deregister()

The WARN_ON(list_empty(&misc->list)) in misc_deregister() does
not catch any practical error conditions:
- For statically allocated miscdevice structures, the list pointers
are zero-initialized, so list_empty() returns false, not true.
- After list_del(), the pointers are set to LIST_POISON1 and LIST_POISON2,
so repeated deregistration also fails to trigger the check.

Signed-off-by: Xion Wang <xion.wang@mediatek.com>
Link: https://lore.kernel.org/r/20250827024201.21407-2-xion.wang@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Xion Wang and committed by
Greg Kroah-Hartman
ceda408c 20f2044b

-3
-3
drivers/char/misc.c
··· 283 283 284 284 void misc_deregister(struct miscdevice *misc) 285 285 { 286 - if (WARN_ON(list_empty(&misc->list))) 287 - return; 288 - 289 286 mutex_lock(&misc_mtx); 290 287 list_del(&misc->list); 291 288 device_destroy(&misc_class, MKDEV(MISC_MAJOR, misc->minor));