From: Denis Kenzior <denkenz@gmail.com>
To: ofono@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH 1/2] modem: remove atom entry prior to invoking the watch callback
Date: Mon, 8 Apr 2024 15:09:03 -0500 [thread overview]
Message-ID: <20240408200905.2983892-1-denkenz@gmail.com> (raw)
In __ofono_atom_free, the atom is removed from the list prior to
invoking __ofono_atom_unregister. This ensures that any invocation of
__ofono_atom_find or __ofono_modem_find_atom() will fail to find the
just-removed object when invoked from the atom watch.
The above does not hold in flush_atoms() implementation, which can lead
to surprising results. Make sure that the atom is removed from the
modem's atom list prior to invoking __ofono_atom_unregister in all
cases.
---
src/modem.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/modem.c b/src/modem.c
index bfd5d7a81c45..7d93c3234e83 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -480,13 +480,6 @@ static void flush_atoms(struct ofono_modem *modem, enum modem_state new_state)
continue;
}
- __ofono_atom_unregister(atom);
-
- if (atom->destruct)
- atom->destruct(atom);
-
- g_free(atom);
-
if (prev)
prev->next = cur->next;
else
@@ -495,6 +488,13 @@ static void flush_atoms(struct ofono_modem *modem, enum modem_state new_state)
tmp = cur;
cur = cur->next;
g_slist_free_1(tmp);
+
+ __ofono_atom_unregister(atom);
+
+ if (atom->destruct)
+ atom->destruct(atom);
+
+ g_free(atom);
}
}
--
2.43.0
next reply other threads:[~2024-04-08 20:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-08 20:09 Denis Kenzior [this message]
2024-04-08 20:09 ` [PATCH 2/2] hfp_ag_bluez5: Fix use-after-free Denis Kenzior
2024-04-08 22:40 ` [PATCH 1/2] modem: remove atom entry prior to invoking the watch callback patchwork-bot+ofono
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=20240408200905.2983892-1-denkenz@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).