From 4d8089697f1bcc494e80f7f5e12ffaa8ecf1282a Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 8 Feb 2014 18:50:30 +0100 Subject: wpa: make sure wpa-ctrl stays around during dispatch If we call into user-callbacks, we need to make sure that they do not free the wpa-object. We want to explicitly allow that so take a ref before calling any callback and drop it afterwards. We already check for !open so we bail out early if sth fails. Signed-off-by: David Herrmann --- src/wpa_ctrl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wpa_ctrl.c b/src/wpa_ctrl.c index fa3a643..34b626a 100644 --- a/src/wpa_ctrl.c +++ b/src/wpa_ctrl.c @@ -561,6 +561,8 @@ int wfd_wpa_ctrl_dispatch(struct wfd_wpa_ctrl *wpa, int timeout) n = max; } + wfd_wpa_ctrl_ref(wpa); + r = 0; for (i = 0; i < n; ++i) { e = &ev[i]; @@ -575,6 +577,8 @@ int wfd_wpa_ctrl_dispatch(struct wfd_wpa_ctrl *wpa, int timeout) break; } + wfd_wpa_ctrl_unref(wpa); + return r; } -- cgit v1.2.3