commit 736aadc75f23331bd0dc8c35c6925c8f381bbb06
parent 40c091ac7fd23c881e1ad7ac2cc2ddb6183dfbeb
Author: Andrew Zaborowski <andrew.zaborowski@intel.com>
Date: Fri, 31 Jul 2020 03:31:24 +0200
frame-xchg: Fix potential use after free
Check if the frame callback has cancelled the frame_xchg before
attempting to free it.
Diffstat:
1 file changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/frame-xchg.c b/src/frame-xchg.c
@@ -975,6 +975,11 @@ static bool frame_xchg_tx_retry(struct wiphy_radio_work_item *item)
return false;
}
+static bool frame_xchg_match_ptr(const void *a, const void *b)
+{
+ return a == b;
+}
+
static bool frame_xchg_resp_handle(const struct mmpdu_header *mpdu,
const void *body, size_t body_len,
int rssi, void *user_data)
@@ -1013,6 +1018,9 @@ static bool frame_xchg_resp_handle(const struct mmpdu_header *mpdu,
done = watch->cb(mpdu, body, body_len, rssi, fx->user_data);
+ if (!l_queue_find(frame_xchgs, frame_xchg_match_ptr, fx))
+ return true;
+
if (done) {
/* NULL callback here since the caller is done */
fx->cb = NULL;