mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: <xion.wang@mediatek.com>
To: Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	Akinobu Mita <akinobu.mita@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: <wsd_upstream@mediatek.com>, <huadian.liu@mediatek.com>,
	Xion Wang <xion.wang@mediatek.com>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-mediatek@lists.infradead.org>
Subject: [PATCH 0/1] char: Use list_del_init() in misc_deregister()
Date: Thu, 4 Sep 2025 14:37:03 +0800	[thread overview]
Message-ID: <20250904063714.28925-1-xion.wang@mediatek.com> (raw)

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

Hi all,

This patch updates the misc_deregister() function to use list_del_init()
instead of list_del() when removing the device from the list.
While list_del() poisons the list pointers to catch invalid usage,
it does not reset the list head. 
If misc_deregister() is called more than once on the same device, 
list_empty() will not return true and list_del() may be called again,
leading to undefined behavior.

By switching to list_del_init(), we ensure the list head is reinitialized,
making the code more robust against double deregistration and
allowing safe usage of list_empty() after deregistration.

Fixes: b329becfc78b1 ("char: add WARN_ON() in misc_deregister()")

Let me know if you have any questions or suggestions.

Thanks,
Xion Wang

Xion Wang (1):
  char: Use list_del_init() in misc_deregister() to reinitialize list
    pointer

 drivers/char/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.45.2


             reply	other threads:[~2025-09-04  6:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-04  6:37 xion.wang [this message]
2025-09-04  6:37 ` [PATCH 1/1] char: Use list_del_init() in misc_deregister() to reinitialize list pointer xion.wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250904063714.28925-1-xion.wang@mediatek.com \
    --to=xion.wang@mediatek.com \
    --cc=akinobu.mita@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=huadian.liu@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=wsd_upstream@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®