[PATCH 1/1] misc: remove ineffective WARN_ON() check from misc_deregister()

xion.wang at mediatek.com xion.wang at mediatek.com
Tue Aug 26 19:41:00 PDT 2025


From: Xion Wang <xion.wang at mediatek.com>

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 at mediatek.com>
---
 drivers/char/misc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 558302a64dd9..f46b00a76a59 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -275,9 +275,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));
-- 
2.45.2




More information about the linux-arm-kernel mailing list