All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: kvalo@kernel.org, quic_jjohnson@quicinc.com
Cc: morbo@google.com, justinstitt@google.com,
	quic_periyasa@quicinc.com,  ath12k@lists.infradead.org,
	linux-wireless@vger.kernel.org,  llvm@lists.linux.dev,
	patches@lists.linux.dev,  Nathan Chancellor <nathan@kernel.org>
Subject: [PATCH] wifi: ath12k: Fix uninitialized use of ret in ath12k_mac_allocate()
Date: Mon, 05 Feb 2024 12:49:53 -0700	[thread overview]
Message-ID: <20240205-ath12k-mac-wuninitialized-v1-1-3fda7b17357f@kernel.org> (raw)

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 6db6e70a17f6 ("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: 6db6e70a17f6 ("wifi: ath12k: Introduce the container for mac80211 hw")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/net/wireless/ath/ath12k/mac.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index fb5bf500ed87..4b0521e8fb26 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -8038,6 +8038,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;
 		}
 

---
base-commit: b82fb7ef690bd929b88d9aab1d191ff502ed9029
change-id: 20240205-ath12k-mac-wuninitialized-1bc5faf17d29

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>


             reply	other threads:[~2024-02-05 19:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-05 19:49 Nathan Chancellor [this message]
2024-02-05 20:50 ` [PATCH] wifi: ath12k: Fix uninitialized use of ret in ath12k_mac_allocate() Jeff Johnson
2024-02-07 15:08 ` Kalle Valo
2024-02-21 18:00   ` Nathan Chancellor
2024-02-21 18:21     ` Kalle Valo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240205-ath12k-mac-wuninitialized-v1-1-3fda7b17357f@kernel.org \
    --to=nathan@kernel.org \
    --cc=ath12k@lists.infradead.org \
    --cc=justinstitt@google.com \
    --cc=kvalo@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=patches@lists.linux.dev \
    --cc=quic_jjohnson@quicinc.com \
    --cc=quic_periyasa@quicinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.