From cdcc8b216042979e1ef1ef841c179730ff890cbf Mon Sep 17 00:00:00 2001 From: Jaya Prakash Sangaru Date: Wed, 8 Aug 2018 10:22:52 +0530 Subject: [PATCH] [9610][7885][7872] wlbt: wifi-hal fix prevent issue If driver does not send mac/cluster address in SLSI_NAN_EVENT_DISCOVERY_ENGinE wifi-hal can crash in processNanDiscoveryEvent(). Avoid such unwanted crash. SCSC-Bug-Id: SSB-42660 Change-Id: I50184d43647e98ba00fbe3f6c4b2762f9c7fdb41 Signed-off-by: Jaya Prakash Sangaru --- wifi_nan.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/wifi_nan.cpp b/wifi_nan.cpp index 358bd86..4c1a208 100755 --- a/wifi_nan.cpp +++ b/wifi_nan.cpp @@ -623,7 +623,7 @@ class NanCommand : public WifiCommand { int processNanDiscoveryEvent(WifiEvent &event) { NanDiscEngEventInd ind; memset(&ind,0,sizeof(ind)); - u8 *addr; + u8 *addr = NULL; for(nl_iterator nl_itr((struct nlattr *)event.get_vendor_data()); nl_itr.has_next(); nl_itr.next()) { switch(nl_itr.get_type()) { @@ -638,10 +638,14 @@ class NanCommand : public WifiCommand { return NL_SKIP; } } - if (ind.event_type == NAN_EVENT_ID_DISC_MAC_ADDR) - memcpy(ind.data.mac_addr.addr, addr, NAN_MAC_ADDR_LEN); - else - memcpy(ind.data.cluster.addr, addr, NAN_MAC_ADDR_LEN); + if (addr) { + if (ind.event_type == NAN_EVENT_ID_DISC_MAC_ADDR) + memcpy(ind.data.mac_addr.addr, addr, NAN_MAC_ADDR_LEN); + else + memcpy(ind.data.cluster.addr, addr, NAN_MAC_ADDR_LEN); + } else { + ALOGE("processNanDiscoveryEvent: No Mac/cluster Address"); + } if (callbackEventHandler.EventDiscEngEvent) callbackEventHandler.EventDiscEngEvent(&ind); -- 2.20.1