qcacld-3.0: Free crypto key entry

Firmware sends WMI_ROAM_SYNCH_KEY_EVENTID after roaming
to 3 Link ML AP. Host allocates memory for every crypto
keys and populates data from the fw event.
This memory is not freed if the addition to crypto
module fails and results in memleak.

Fix is to free the crypto key entry when addition fails.

CRs-Fixed: 3678765
Change-Id: Ife70261b697ec016f50d4e0730c3fa4fc0ec06ab
Šī revīzija ir iekļauta:
Amruta Kulkarni
2023-12-05 13:38:08 -08:00
revīziju iesūtīja Ravindra Konda
vecāks a902a54ed0
revīzija 4292b68281
2 mainīti faili ar 11 papildinājumiem un 4 dzēšanām

Parādīt failu

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2012-2021 The Linux Foundation. All rights reserved.
* Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@@ -504,9 +504,14 @@ QDF_STATUS cm_roam_sync_key_event_handler(struct wlan_objmgr_psoc *psoc,
for (i = 0; i < num_keys; i++) {
status = wlan_crypto_add_key_entry(psoc, &keys[i]);
if (QDF_IS_STATUS_ERROR(status))
if (QDF_IS_STATUS_ERROR(status)) {
mlme_err("Failed to add key entry for link:%d",
keys[i].link_id);
wlan_crypto_free_key(&keys[i].keys);
qdf_mem_zero(&keys[i],
sizeof(struct wlan_crypto_key_entry));
qdf_mem_free(&keys[i]);
}
}
return status;

Parādīt failu

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -4145,10 +4145,12 @@ free_keys:
if (!key_alloc_buf[k])
continue;
wmi_err_rl("flush keybuf :%d, key is valid", flush_keybuf,
key_alloc_buf[k]->valid);
if (!flush_keybuf && key_alloc_buf[k]->valid)
continue;
wmi_debug("Free key allocated at idx:%d", k);
wmi_err("Free key allocated at idx:%d", k);
qdf_mem_zero(key_alloc_buf[k], sizeof(*key_alloc_buf[k]));
qdf_mem_free(key_alloc_buf[k]);
}