From: Riccardo Oliva <oliva.scorza@gmail.com>
To: lee@kernel.org
Cc: mfd@lists.linux.dev, linux-kernel@vger.kernel.org,
Riccardo Oliva <oliva.scorza@gmail.com>
Subject: [PATCH v2] mfd: dln2: Clean up dln2_unregister_event_cb() loop logic
Date: Tue, 27 Oct 2026 21:15:56 -0500 [thread overview]
Message-ID: <20261028021556.11988-1-oliva.scorza@gmail.com> (raw)
In-Reply-To: <179198398105.839288.1873130512029656566@kernel.org>
Streamline dln2_unregister_event_cb() by using a dedicated 'entry'
pointer to store the matching event callback. This removes the need
for the 'found' boolean flag, restricts the iterator scope, and matches
the pattern used in dln2_register_event_cb().
Assisted-by: coccinelle sparse
Signed-off-by: Riccardo Oliva <oliva.scorza@gmail.com>
---
v2:
- Rephrase commit log: Clarified this is a cleanup rather than a bug fix
- Rename 'target' to 'entry' for consistency
drivers/mfd/dln2.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
index 0b1e7fd7f..2a9d83d32 100644
--- a/drivers/mfd/dln2.c
+++ b/drivers/mfd/dln2.c
@@ -157,25 +157,24 @@ EXPORT_SYMBOL(dln2_register_event_cb);
void dln2_unregister_event_cb(struct platform_device *pdev, u16 id)
{
struct dln2_dev *dln2 = dev_get_drvdata(pdev->dev.parent);
- struct dln2_event_cb_entry *i;
+ struct dln2_event_cb_entry *i, *entry = NULL;
unsigned long flags;
- bool found = false;
spin_lock_irqsave(&dln2->event_cb_lock, flags);
list_for_each_entry(i, &dln2->event_cb_list, list) {
if (i->id == id) {
list_del_rcu(&i->list);
- found = true;
+ entry = i;
break;
}
}
spin_unlock_irqrestore(&dln2->event_cb_lock, flags);
- if (found) {
+ if (entry) {
synchronize_rcu();
- kfree(i);
+ kfree(entry);
}
}
EXPORT_SYMBOL(dln2_unregister_event_cb);
--
2.43.0
prev parent reply other threads:[~2026-10-28 2:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 23:42 [PATCH] mfd: dln2: Fix use-after-free risk in list iterator Riccardo Oliva
2026-10-20 9:59 ` Lee Jones
2026-10-28 2:15 ` Riccardo Oliva [this message]
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=20261028021556.11988-1-oliva.scorza@gmail.com \
--to=oliva.scorza@gmail.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mfd@lists.linux.dev \
/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®