linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] misc: remove ineffective WARN_ON() check from misc_deregister()
@ 2025-08-27  2:40 xion.wang
  2025-08-27  2:41 ` [PATCH 1/1] " xion.wang
  0 siblings, 1 reply; 2+ messages in thread
From: xion.wang @ 2025-08-27  2:40 UTC (permalink / raw)
  To: Arnd Bergmann, Greg Kroah-Hartman, Matthias Brugger,
	AngeloGioacchino Del Regno
  Cc: wsd_upstream, huadian.liu, Xion Wang, linux-kernel,
	linux-arm-kernel, linux-mediatek

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

Hi All,

This patch removes the ineffective WARN_ON(list_empty(&misc->list)) 
check from misc_deregister(). Please see the commit message for details.

Xion Wang (1):
  misc: remove ineffective WARN_ON() check from misc_deregister()

 drivers/char/misc.c | 3 ---
 1 file changed, 3 deletions(-)

-- 
2.45.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 1/1] misc: remove ineffective WARN_ON() check from misc_deregister()
  2025-08-27  2:40 [PATCH 0/1] misc: remove ineffective WARN_ON() check from misc_deregister() xion.wang
@ 2025-08-27  2:41 ` xion.wang
  0 siblings, 0 replies; 2+ messages in thread
From: xion.wang @ 2025-08-27  2:41 UTC (permalink / raw)
  To: Arnd Bergmann, Greg Kroah-Hartman, Matthias Brugger,
	AngeloGioacchino Del Regno
  Cc: wsd_upstream, huadian.liu, Xion Wang, linux-kernel,
	linux-arm-kernel, linux-mediatek

From: Xion Wang <xion.wang@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@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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-27  2:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-27  2:40 [PATCH 0/1] misc: remove ineffective WARN_ON() check from misc_deregister() xion.wang
2025-08-27  2:41 ` [PATCH 1/1] " xion.wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).