[automerger skipped] Merge "Merge Android 14" into main am: 2ae324a109 -s ours am: 52df4c8b8f -s ours am: ea1553b58d -s ours am: c7b27e319d -s ours

am skip reason: Merged-In I89e8dbd1b2e937c6ed8dc19f77cd014c99bd79f0 with SHA-1 6d476be900 is already in history

Original change: https://android-review.googlesource.com/c/platform/hardware/broadcom/wlan/+/2775964

Change-Id: I85c40c1d8c8b799e2556f8c89639d35e2209e693
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/bcmdhd/wifi_hal/common.cpp b/bcmdhd/wifi_hal/common.cpp
index 1a55aac..7f164ab 100755
--- a/bcmdhd/wifi_hal/common.cpp
+++ b/bcmdhd/wifi_hal/common.cpp
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
  *
- * Portions copyright (C) 2017 Broadcom Limited
+ * Portions copyright (C) 2023 Broadcom Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/bcmdhd/wifi_hal/common.h b/bcmdhd/wifi_hal/common.h
index d8392c8..acb649f 100644
--- a/bcmdhd/wifi_hal/common.h
+++ b/bcmdhd/wifi_hal/common.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
  *
- * Portions copyright (C) 2017 Broadcom Limited
+ * Portions copyright (C) 2023 Broadcom Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/bcmdhd/wifi_hal/cpp_bindings.cpp b/bcmdhd/wifi_hal/cpp_bindings.cpp
index a7d6241..8ef0ca8 100755
--- a/bcmdhd/wifi_hal/cpp_bindings.cpp
+++ b/bcmdhd/wifi_hal/cpp_bindings.cpp
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
  *
- * Portions copyright (C) 2017 Broadcom Limited
+ * Portions copyright (C) 2023 Broadcom Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -658,6 +658,11 @@
         goto out;
     }
 
+    if (!mInfo->cmd_sock) {
+        ALOGE("cmd_sock is already freed mInfo:%p mIfaceInfo:%p\n", mInfo, mIfaceInfo);
+        goto out;
+    }
+
     err = nl_send_auto_complete(mInfo->cmd_sock, request.getMessage());    /* send message */
     if (err < 0)
         goto out;
diff --git a/bcmdhd/wifi_hal/cpp_bindings.h b/bcmdhd/wifi_hal/cpp_bindings.h
index cc1c662..69b699c 100755
--- a/bcmdhd/wifi_hal/cpp_bindings.h
+++ b/bcmdhd/wifi_hal/cpp_bindings.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
  *
- * Portions copyright (C) 2017 Broadcom Limited
+ * Portions copyright (C) 2023 Broadcom Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/bcmdhd/wifi_hal/gscan.cpp b/bcmdhd/wifi_hal/gscan.cpp
index 19bab2b..eaddc53 100755
--- a/bcmdhd/wifi_hal/gscan.cpp
+++ b/bcmdhd/wifi_hal/gscan.cpp
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
  *
- * Portions copyright (C) 2017 Broadcom Limited
+ * Portions copyright (C) 2023 Broadcom Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/bcmdhd/wifi_hal/link_layer_stats.cpp b/bcmdhd/wifi_hal/link_layer_stats.cpp
index f3460c2..c17b3b8 100644
--- a/bcmdhd/wifi_hal/link_layer_stats.cpp
+++ b/bcmdhd/wifi_hal/link_layer_stats.cpp
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
  *
- * Portions copyright (C) 2017 Broadcom Limited
+ * Portions copyright (C) 2023 Broadcom Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/bcmdhd/wifi_hal/nan.cpp b/bcmdhd/wifi_hal/nan.cpp
index 1f7b2ce..d0f7b5a 100644
--- a/bcmdhd/wifi_hal/nan.cpp
+++ b/bcmdhd/wifi_hal/nan.cpp
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
  *
- * Portions copyright (C) 2017 Broadcom Limited
+ * Portions copyright (C) 2023 Broadcom Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -2454,8 +2454,11 @@
              } else {
                  rsp_data.status = NAN_STATUS_INTERNAL_FAILURE;
              }
-         } else if (reply.get_cmd() != NL80211_CMD_VENDOR || reply.get_vendor_data() == NULL) {
-            ALOGD("Ignoring reply with cmd = %d", reply.get_cmd());
+        } else if (reply.get_cmd() != NL80211_CMD_VENDOR ||
+                    reply.get_vendor_data() == NULL ||
+                    reply.get_vendor_data_len() != sizeof(nan_hal_resp_t)) {
+            ALOGD("Ignoring reply with cmd = %d mType = %d len = %d\n",
+                    reply.get_cmd(), mType, reply.get_vendor_data_len());
             return NL_SKIP;
         } else {
             rsp_vndr_data = (nan_hal_resp_t *)reply.get_vendor_data();
diff --git a/bcmdhd/wifi_hal/rtt.cpp b/bcmdhd/wifi_hal/rtt.cpp
index 2197c81..4167c4f 100644
--- a/bcmdhd/wifi_hal/rtt.cpp
+++ b/bcmdhd/wifi_hal/rtt.cpp
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
  *
- * Portions copyright (C) 2017 Broadcom Limited
+ * Portions copyright (C) 2023 Broadcom Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/bcmdhd/wifi_hal/scan.cpp b/bcmdhd/wifi_hal/scan.cpp
index d8ab4e0..0358092 100644
--- a/bcmdhd/wifi_hal/scan.cpp
+++ b/bcmdhd/wifi_hal/scan.cpp
@@ -1,7 +1,7 @@
 /*

  * Copyright (C) 2022 The Android Open Source Project

  *

- * Portions copyright (C) 2022 Broadcom Limited

+ * Portions copyright (C) 2023 Broadcom Limited

  *

  * Licensed under the Apache License, Version 2.0 (the "License");

  * you may not use this file except in compliance with the License.

diff --git a/bcmdhd/wifi_hal/sync.h b/bcmdhd/wifi_hal/sync.h
index 1118c71..91c017f 100644
--- a/bcmdhd/wifi_hal/sync.h
+++ b/bcmdhd/wifi_hal/sync.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
  *
- * Portions copyright (C) 2017 Broadcom Limited
+ * Portions copyright (C) 2023 Broadcom Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/bcmdhd/wifi_hal/twt.cpp b/bcmdhd/wifi_hal/twt.cpp
index 63cd002..087c17a 100755
--- a/bcmdhd/wifi_hal/twt.cpp
+++ b/bcmdhd/wifi_hal/twt.cpp
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
  *
- * Portions copyright (C) 2020 Broadcom Limited
+ * Portions copyright (C) 2023 Broadcom Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/bcmdhd/wifi_hal/wifi_hal.cpp b/bcmdhd/wifi_hal/wifi_hal.cpp
index 74e869a..af9b06c 100644
--- a/bcmdhd/wifi_hal/wifi_hal.cpp
+++ b/bcmdhd/wifi_hal/wifi_hal.cpp
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
  *
- * Portions copyright (C) 2017 Broadcom Limited
+ * Portions copyright (C) 2023 Broadcom Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -710,13 +710,13 @@
             ALOGI("Cancelling command %p:%s", cmd, cmd->getType());
             pthread_mutex_unlock(&info->cb_lock);
             cmd->cancel();
-            pthread_mutex_lock(&info->cb_lock);
             if (num_cmd == info->num_cmd) {
                 ALOGI("Cancelling command %p:%s did not work", cmd, (cmd ? cmd->getType(): ""));
                 bad_commands++;
             }
             /* release reference added when command is saved */
             cmd->releaseRef();
+            pthread_mutex_lock(&info->cb_lock);
         }
     }
 
@@ -1098,7 +1098,7 @@
          */
         ALOGI("Try to remove event handler if exist, vendor 0x%0x, subcmd 0x%x",
             GOOGLE_OUI, GOOGLE_RSSI_MONITOR_EVENT);
-        unregisterVendorHandlerWithoutLock(GOOGLE_OUI, GOOGLE_RSSI_MONITOR_EVENT);
+        unregisterVendorHandler(GOOGLE_OUI, GOOGLE_RSSI_MONITOR_EVENT);
         ALOGI("SetRSSIMonitorCommand %p destroyed", this);
    }
 
diff --git a/bcmdhd/wifi_hal/wifi_logger.cpp b/bcmdhd/wifi_hal/wifi_logger.cpp
index 9d83719..694df19 100755
--- a/bcmdhd/wifi_hal/wifi_logger.cpp
+++ b/bcmdhd/wifi_hal/wifi_logger.cpp
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
  *
- * Portions copyright (C) 2017 Broadcom Limited
+ * Portions copyright (C) 2023 Broadcom Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -524,32 +524,39 @@
 } sku_info_t;
 
 sku_info_t sku_table[] = {
+    // BCM4389
     { {"G9S9B"}, {"MMW"} },
     { {"G8V0U"}, {"MMW"} },
     { {"GFQM1"}, {"MMW"} },
     { {"GB62Z"}, {"MMW"} },
     { {"GE2AE"}, {"MMW"} },
     { {"GQML3"}, {"MMW"} },
-    { {"GKWS6"}, {"MMW"} },
-    { {"G1MNW"}, {"MMW"} },
     { {"GB7N6"}, {"ROW"} },
     { {"GLU0G"}, {"ROW"} },
     { {"GNA8F"}, {"ROW"} },
     { {"GX7AS"}, {"ROW"} },
     { {"GP4BC"}, {"ROW"} },
     { {"GVU6C"}, {"ROW"} },
-    { {"GPJ41"}, {"ROW"} },
-    { {"GC3VE"}, {"ROW"} },
     { {"GR1YH"}, {"JPN"} },
     { {"GF5KQ"}, {"JPN"} },
     { {"GPQ72"}, {"JPN"} },
     { {"GB17L"}, {"JPN"} },
     { {"GFE4J"}, {"JPN"} },
     { {"G03Z5"}, {"JPN"} },
+    // BCM4398
+    { {"GKWS6"}, {"MMW"} },
+    { {"G1MNW"}, {"MMW"} },
+    { {"GPJ41"}, {"ROW"} },
+    { {"GC3VE"}, {"ROW"} },
     { {"GE9DP"}, {"JPN"} },
     { {"GZPF0"}, {"JPN"} },
     { {"G1AZG"}, {"EU"} },
-    { {"G9BQD"}, {"NA"} }
+    { {"G9BQD"}, {"NA"} },
+    // BCM4383
+    { {"G8HHN"}, {"MMW"} },
+    { {"G6GPR"}, {"ROW"} },
+    { {"G576D"}, {"JPN"} },
+    { {"GKV4X"}, {"NA"} }
 };
 ///////////////////////////////////////////////////////////////////////////////
 class DebugCommand : public WifiCommand
@@ -1658,6 +1665,7 @@
         : WifiCommand("RingDump", iface, id), mLargestBuffSize(0), mBuff(NULL),
         mErrCode(0)
     {
+        memset(&mHandle, 0, sizeof(wifi_ring_buffer_data_handler));
     }
 
     int start() {
@@ -1698,6 +1706,7 @@
                 ring_name[i] = NULL;
             }
         }
+        memset(&mHandle, 0, sizeof(wifi_ring_buffer_data_handler));
 
         DUMP_INFO(("Stop Ring Dump Successfully Completed, mErrCode = %d\n", mErrCode));
         return WIFI_SUCCESS;
@@ -2343,6 +2352,7 @@
     int createMonitorPktFateRequest(WifiRequest& request) {
         int result = request.create(GOOGLE_OUI, LOGGER_START_PKT_FATE_MONITORING);
         if (result < 0) {
+            ALOGE("Failed to create monitorPktFate result:%d\n", result);
             return result;
         }
 
@@ -2354,6 +2364,7 @@
     int createTxPktFateRequest(WifiRequest& request) {
         int result = request.create(GOOGLE_OUI, LOGGER_GET_TX_PKT_FATES);
         if (result < 0) {
+            ALOGE("Failed to create TxPktFate result:%d\n", result);
             return result;
         }
 
@@ -2361,10 +2372,12 @@
         nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
         result = request.put_u32(LOGGER_ATTRIBUTE_PKT_FATE_NUM, mNoReqFates);
         if (result < 0) {
+            ALOGE("Failed to set TxPktFate num result:%d mNoReqFates:%d\n", result, mNoReqFates);
             return result;
         }
         result = request.put_u64(LOGGER_ATTRIBUTE_PKT_FATE_DATA, (uint64_t)mReportBufs);
         if (result < 0) {
+            ALOGE("Failed to set TxPktFate buf result:%d\n", result);
             return result;
         }
         request.attr_end(data);
@@ -2374,6 +2387,7 @@
     int createRxPktFateRequest(WifiRequest& request) {
         int result = request.create(GOOGLE_OUI, LOGGER_GET_RX_PKT_FATES);
         if (result < 0) {
+            ALOGE("Failed to create RxPktFate result:%d\n", result);
             return result;
         }
 
@@ -2381,10 +2395,12 @@
         nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
         result = request.put_u32(LOGGER_ATTRIBUTE_PKT_FATE_NUM, mNoReqFates);
         if (result < 0) {
+            ALOGE("Failed to set RxPktFate num result:%d mNoReqFates:%d\n", result, mNoReqFates);
             return result;
         }
         result = request.put_u64(LOGGER_ATTRIBUTE_PKT_FATE_DATA, (uint64_t)mReportBufs);
         if (result < 0) {
+            ALOGE("Failed to set RxPktFate buf result:%d\n", result);
             return result;
         }
         request.attr_end(data);
diff --git a/bcmdhd/wifi_hal/wifi_offload.cpp b/bcmdhd/wifi_hal/wifi_offload.cpp
index a24a882..d80b182 100644
--- a/bcmdhd/wifi_hal/wifi_offload.cpp
+++ b/bcmdhd/wifi_hal/wifi_offload.cpp
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
  *
- * Portions copyright (C) 2017 Broadcom Limited
+ * Portions copyright (C) 2023 Broadcom Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.