Skip to content

Commit

Permalink
wifi: ath12k: Fix uninitialized use of ret in ath12k_mac_allocate()
Browse files Browse the repository at this point in the history
Clang warns (or errors with CONFIG_WERROR=y):

  drivers/net/wireless/ath/ath12k/mac.c:8060:9: error: variable 'ret' is uninitialized when used here [-Werror,-Wuninitialized]
   8060 |         return ret;
        |                ^~~
  drivers/net/wireless/ath/ath12k/mac.c:8022:9: note: initialize the variable 'ret' to silence this warning
   8022 |         int ret, i, j;
        |                ^
        |                 = 0
  1 error generated.

Commit 6db6e70 ("wifi: ath12k: Introduce the container for mac80211
hw") added a completely uninitialized use of ret. Prior to that change,
-ENOMEM was returned to the callers of ath12k_mac_allocate() whenever
ath12k_mac_hw_allocate() failed. Assign that value to ret to make sure
it is always initialized when used and clear up the warning.

Closes: https://github.com/ClangBuiltLinux/linux/issues/1989i
Fixes: 6db6e70 ("wifi: ath12k: Introduce the container for mac80211 hw")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://msgid.link/20240205-ath12k-mac-wuninitialized-v1-1-3fda7b17357f@kernel.org
  • Loading branch information
Nathan Chancellor authored and Kalle Valo committed Feb 7, 2024
1 parent d7a5c7c commit 04edb5d
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/net/wireless/ath/ath12k/mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -8302,6 +8302,7 @@ int ath12k_mac_allocate(struct ath12k_base *ab)
if (!ah) {
ath12k_warn(ab, "failed to allocate mac80211 hw device for hw_idx %d\n",
i);
ret = -ENOMEM;
goto err;
}

Expand Down

0 comments on commit 04edb5d

Please sign in to comment.