[APR-1563] wlbt: Prevent issues in APF in wifi_hal
authorSrishti Piplani <srishti.p@samsung.com>
Tue, 20 Aug 2019 14:02:02 +0000 (19:32 +0530)
committerKim Gunho <gunho.kim@samsung.com>
Mon, 9 Sep 2019 08:01:28 +0000 (17:01 +0900)
Code changes to fix prevent issues in wifi_hal in APF.

SCSC-Bug-Id: HOST-10738
Signed-off-by: Srishti Piplani <srishti.p@samsung.com>
Change-Id: I93703d9437f15d9dcc3772e3ff007811b3b9914f

wifi_hal.cpp

index 6e0ab1c94a99be0051c2f76755147c2e82241543..8e5d4dcdcd96111cdd41b0c092007ec40e4d2280 100755 (executable)
@@ -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;
     }