]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
misc: remove ineffective WARN_ON() check from misc_deregister()
authorXion Wang <xion.wang@mediatek.com>
Wed, 27 Aug 2025 02:41:00 +0000 (10:41 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 6 Sep 2025 17:41:07 +0000 (19:41 +0200)
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>
drivers/char/misc.c

index a0aae0fc792666a7bdc0ba00da9dc02ff9cead42..69e8ce02e099f27602dfb36771eb0f7f97b8a924 100644 (file)
@@ -283,9 +283,6 @@ EXPORT_SYMBOL(misc_register);
 
 void misc_deregister(struct miscdevice *misc)
 {
-       if (WARN_ON(list_empty(&misc->list)))
-               return;
-
        mutex_lock(&misc_mtx);
        list_del(&misc->list);
        device_destroy(&misc_class, MKDEV(MISC_MAJOR, misc->minor));