From f7b3e8f61af3ca6cef26ca5e46117a69b57b2579 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Dhanotiya Date: Thu, 11 Aug 2022 18:24:52 +0530 Subject: [PATCH] qcacld-3.0: Free wifi features sysfs file only if it is created Currently driver creates sysfs features file if fw provides file name in oem data event, but it tries to free without any condition, this leeds to an unexpected behaviour if fw does not provides file name in oem data event. To address above issue, free wifi features sysfs file only if fw provides file name in oem data event. Change-Id: Ida6a69846638ba6edd5d0e5322323ef66433b364 CRs-Fixed: 3266097 --- core/hdd/src/wlan_hdd_sysfs_wifi_features.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/core/hdd/src/wlan_hdd_sysfs_wifi_features.c b/core/hdd/src/wlan_hdd_sysfs_wifi_features.c index 079713c39b..71539b23d1 100644 --- a/core/hdd/src/wlan_hdd_sysfs_wifi_features.c +++ b/core/hdd/src/wlan_hdd_sysfs_wifi_features.c @@ -77,12 +77,12 @@ void hdd_sysfs_create_wifi_feature_interface(struct kobject *wifi_kobject) if (!hdd_ctx) return; - if (!wifi_kobject) { - hdd_err("could not get wifi kobject!"); + if (!hdd_ctx->oem_data_len || !hdd_ctx->file_name) { + hdd_err("Invalid oem data length or file name"); return; } - if (!hdd_ctx->oem_data_len) { - hdd_err("Invalid oem data length"); + if (!wifi_kobject) { + hdd_err("could not get wifi kobject!"); return; } feature_set_attribute.attr.name = hdd_ctx->file_name; @@ -98,6 +98,18 @@ void hdd_sysfs_create_wifi_feature_interface(struct kobject *wifi_kobject) void hdd_sysfs_destroy_wifi_feature_interface(struct kobject *wifi_kobject) { + struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); + + if (!hdd_ctx) { + hdd_err("HDD context is NULL"); + return; + } + + if (!hdd_ctx->file_name) { + hdd_debug("file name is NULL"); + return; + } + if (!wifi_kobject) { hdd_err("could not get wifi kobject!"); return;