From: Jaganath Kanakkassery <jaganath.k@samsung.com>
To: linux-bluetooth@vger.kernel.org
Cc: Jaganath Kanakkassery <jaganath.k@samsung.com>
Subject: [PATCH BlueZ v1 2/2] attrib: Fix use after free of attrib
Date: Mon, 01 Apr 2013 15:08:01 +0530 [thread overview]
Message-ID: <1364809081-1796-2-git-send-email-jaganath.k@samsung.com> (raw)
In-Reply-To: <1364809081-1796-1-git-send-email-jaganath.k@samsung.com>
If attrib is freed in cmd->func(), then it will be used if either
request or response queue has some data to send.
This patch moves calling wake_up_sender() which increases the ref
count of attrib so that it wont get freed in cmd->func().
---
attrib/gattrib.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index f95f2fb..37581a3 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -446,6 +446,10 @@ static gboolean received_data(GIOChannel *io, GIOCondition cond, gpointer data)
status = 0;
done:
+ if (!g_queue_is_empty(attrib->requests) ||
+ !g_queue_is_empty(attrib->responses))
+ wake_up_sender(attrib);
+
if (cmd) {
if (cmd->func)
cmd->func(status, buf, len, cmd->user_data);
@@ -453,10 +457,6 @@ done:
command_destroy(cmd);
}
- if (!g_queue_is_empty(attrib->requests) ||
- !g_queue_is_empty(attrib->responses))
- wake_up_sender(attrib);
-
return TRUE;
}
--
1.7.9.5
next prev parent reply other threads:[~2013-04-01 9:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-01 9:38 [PATCH BlueZ v1 1/2] attrib: Remove norequests and noresponses variables Jaganath Kanakkassery
2013-04-01 9:38 ` Jaganath Kanakkassery [this message]
2013-04-02 6:47 ` 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=1364809081-1796-2-git-send-email-jaganath.k@samsung.com \
--to=jaganath.k@samsung.com \
--cc=linux-bluetooth@vger.kernel.org \
/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