wifi: iwlwifi: Fix uninitialized variable with __free()
authorDan Carpenter <dan.carpenter@linaro.org>
Wed, 12 Mar 2025 08:31:40 +0000 (11:31 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 12 Mar 2025 09:41:56 +0000 (10:41 +0100)
Pointers declared with the __free(kfree) attribute need to be initialized
because they will be passed to kfree() on every return path.  There are
two return statement before the "cmd" pointer is initialized so this
leads to an uninitialized variable bug.

Fixes: d1e879ec600f ("wifi: iwlwifi: add iwlmld sub-driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/f7c17a7f-f173-43bf-bc39-316b8adde349@stanley.mountain
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/mld/debugfs.c

index c759c5c68dc0471976897a869206f546fc177dc4..1d4b2ad5d3889fed877284f90fdb939efa678c59 100644 (file)
@@ -556,8 +556,8 @@ iwl_dbgfs_vif_twt_setup_write(struct iwl_mld *mld, char *buf, size_t count,
        };
        struct ieee80211_vif *vif = data;
        struct iwl_mld_vif *mld_vif = iwl_mld_vif_from_mac80211(vif);
+       struct iwl_dhc_cmd *cmd __free(kfree) = NULL;
        struct iwl_dhc_twt_operation *dhc_twt_cmd;
-       struct iwl_dhc_cmd *cmd __free(kfree);
        u64 target_wake_time;
        u32 twt_operation, interval_exp, interval_mantissa, min_wake_duration;
        u8 trigger, flow_type, flow_id, protection, tenth_param;