From: Mikel Astiz <mikel.astiz.oss@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Mikel Astiz <mikel.astiz@bmw-carit.de>
Subject: [PATCH] device: Fix modifying list while iterating
Date: Wed, 17 Oct 2012 12:07:09 +0200 [thread overview]
Message-ID: <1350468429-30882-1-git-send-email-mikel.astiz.oss@gmail.com> (raw)
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
A list should not be modified while iterating on it, and in this case
the solution is trivial: the code is just trying to free the whole list
with a previous call to profile->device_remove() per list item.
---
src/device.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/device.c b/src/device.c
index f48faba..bb0f890 100644
--- a/src/device.c
+++ b/src/device.c
@@ -872,8 +872,6 @@ static void profile_remove(struct btd_profile *profile,
struct btd_device *device)
{
profile->device_remove(profile, device);
-
- device->profiles = g_slist_remove(device->profiles, profile);
}
static gboolean do_disconnect(gpointer user_data)
@@ -899,6 +897,8 @@ int device_block(struct btd_device *device, gboolean update_only)
do_disconnect(device);
g_slist_foreach(device->profiles, (GFunc) profile_remove, device);
+ g_slist_free(device->profiles);
+ device->profiles = NULL;
if (!update_only)
err = btd_adapter_block_address(device->adapter,
--
1.7.11.7
next reply other threads:[~2012-10-17 10:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-17 10:07 Mikel Astiz [this message]
2012-10-17 10:42 ` [PATCH] device: Fix modifying list while iterating Johan Hedberg
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=1350468429-30882-1-git-send-email-mikel.astiz.oss@gmail.com \
--to=mikel.astiz.oss@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=mikel.astiz@bmw-carit.de \
/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