All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Igor Mitsyanko <imitsyanko@quantenna.com>,
	Avinash Patil <avinashp@quantenna.com>,
	Sergey Matyukevich <smatyukevich@quantenna.com>,
	Kalle Valo <kvalo@codeaurora.org>,
	"David S. Miller" <davem@davemloft.net>,
	Vasily Ulyanov <vulyanov@quantenna.com>,
	Andrey Shevchenko <ashevchenko@quantenna.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] qtnfmac: avoid uninitialized variable access
Date: Tue,  9 Oct 2018 17:57:35 +0200	[thread overview]
Message-ID: <20181009155757.494212-1-arnd@arndb.de> (raw)

When qtnf_trans_send_cmd_with_resp() fails, we have not yet initialized
'resp', as pointed out by a valid gcc warning:

drivers/net/wireless/quantenna/qtnfmac/commands.c: In function 'qtnf_cmd_send_with_reply':
drivers/net/wireless/quantenna/qtnfmac/commands.c:133:54: error: 'resp' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Since 'resp_skb' is also not set here, we can skip all further
processing and just print the warning and return the failure code.

Fixes: c6ed298ffe09 ("qtnfmac: cleanup and unify command error handling")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/wireless/quantenna/qtnfmac/commands.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c
index bfdc1ad30c13..9b211459684a 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/commands.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c
@@ -111,7 +111,7 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus,
 
 	ret = qtnf_trans_send_cmd_with_resp(bus, cmd_skb, &resp_skb);
 	if (ret)
-		goto out;
+		goto out_noresp;
 
 	resp = (const struct qlink_resp *)resp_skb->data;
 	ret = qtnf_cmd_check_reply_header(resp, cmd_id, mac_id, vif_id,
@@ -132,6 +132,7 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus,
 	if (!ret && resp)
 		return qtnf_cmd_resp_result_decode(le16_to_cpu(resp->result));
 
+out_noresp:
 	pr_warn("VIF%u.%u: cmd 0x%.4X failed: %d\n",
 		mac_id, vif_id, le16_to_cpu(cmd->cmd_id), ret);
 
-- 
2.18.0


             reply	other threads:[~2018-10-09 15:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-09 15:57 Arnd Bergmann [this message]
2018-10-09 20:25 ` [PATCH] qtnfmac: avoid uninitialized variable access Sergey Matyukevich
2018-10-10 14:56   ` Sergey Matyukevich
2018-10-11  8:08     ` 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=20181009155757.494212-1-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=ashevchenko@quantenna.com \
    --cc=avinashp@quantenna.com \
    --cc=davem@davemloft.net \
    --cc=imitsyanko@quantenna.com \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=smatyukevich@quantenna.com \
    --cc=vulyanov@quantenna.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.