From 4c342f2c40523d96a40a77e80a415295d2e7cfad Mon Sep 17 00:00:00 2001 From: Srishti Piplani Date: Tue, 20 Aug 2019 19:32:02 +0530 Subject: [PATCH] [APR-1563] wlbt: Prevent issues in APF in wifi_hal Code changes to fix prevent issues in wifi_hal in APF. SCSC-Bug-Id: HOST-10738 Signed-off-by: Srishti Piplani Change-Id: I93703d9437f15d9dcc3772e3ff007811b3b9914f --- wifi_hal.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/wifi_hal.cpp b/wifi_hal.cpp index 6e0ab1c..8e5d4dc 100755 --- a/wifi_hal.cpp +++ b/wifi_hal.cpp @@ -90,10 +90,10 @@ class AndroidPktFilterCommand : public WifiCommand { const u8* mProgram; u32 mProgramLen; u32* mVersion; - u32* mMaxLen; + u32* mMaxLen = 0; u32 mSourceOffset; u8 *mHostDestination; - u32 mLength; + u32 mLength = 0; int mReqType; public: AndroidPktFilterCommand(wifi_interface_handle handle, @@ -139,23 +139,24 @@ class AndroidPktFilterCommand : public WifiCommand { int createSetPktFilterRequest(WifiRequest& request) { u8 *program = new u8[mProgramLen]; + nlattr *data = NULL; NULL_CHECK_RETURN(program, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY); int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_APF_SET_FILTER); - if (result < 0) { - return result; - } + if (result < 0) + goto exit; - nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA); + data = request.attr_start(NL80211_ATTR_VENDOR_DATA); result = request.put_u32(APF_ATTRIBUTE_PROGRAM_LEN, mProgramLen); - if (result < 0) { - return result; - } + if (result < 0) + goto exit; + memcpy(program, mProgram, mProgramLen); result = request.put(APF_ATTRIBUTE_PROGRAM, program, mProgramLen); - if (result < 0) { - return result; - } + if (result < 0) + goto exit; request.attr_end(data); + +exit: delete[] program; return result; } -- 2.20.1