diff mbox

mac80211: fix uninitialized variable

Message ID 1364461894-30555-1-git-send-email-vincent.stehle@laposte.net (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Vincent Stehlé March 28, 2013, 9:11 a.m. UTC
Fix one code path where chanctx_conf is tested as being non-NULL while it may
be uninitialized.

This fixes the following warning:

  net/mac80211/tx.c: In function ‘ieee80211_subif_start_xmit’:
  net/mac80211/tx.c:1828:27: warning: ‘chanctx_conf’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net>
Cc: Johannes Berg <johannes@sipsolutions.net>
---
 net/mac80211/tx.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Johannes Berg March 28, 2013, 9:21 a.m. UTC | #1
On Thu, 2013-03-28 at 10:11 +0100, Vincent wrote:
> Fix one code path where chanctx_conf is tested as being non-NULL while it may
> be uninitialized.

No, you're wrong, presumably misled by the compiler.

johannes

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sedat Dilek March 28, 2013, 11:28 a.m. UTC | #2
On Thu, Mar 28, 2013 at 10:21 AM, Johannes Berg
<johannes@sipsolutions.net> wrote:
> On Thu, 2013-03-28 at 10:11 +0100, Vincent wrote:
>> Fix one code path where chanctx_conf is tested as being non-NULL while it may
>> be uninitialized.
>
> No, you're wrong, presumably misled by the compiler.
>

Hi,

especially, when you use gcc >=4.7.x compiler with "-Os"
optimize-level you and your binaries/libs get confused.
Arnd Bergmann sent a patch for these "false-positives" (use
"-Wmaybe-uninitialized" as a CFLAGS).
I think this is a good idea.
If more kernel-developers ACK it, it might get mainline :-)?
Gogogo johill (but don't runaway) :-)...

For more details see also gcc-docs on how to suppress errors and treat
them as warnings [1].

Regards,
- Sedat -

[1] http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-Options

> johannes
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sedat Dilek March 28, 2013, 11:30 a.m. UTC | #3
On Thu, Mar 28, 2013 at 12:28 PM, Sedat Dilek <sedat.dilek@gmail.com> wrote:
> On Thu, Mar 28, 2013 at 10:21 AM, Johannes Berg
> <johannes@sipsolutions.net> wrote:
>> On Thu, 2013-03-28 at 10:11 +0100, Vincent wrote:
>>> Fix one code path where chanctx_conf is tested as being non-NULL while it may
>>> be uninitialized.
>>
>> No, you're wrong, presumably misled by the compiler.
>>
>
> Hi,
>
> especially, when you use gcc >=4.7.x compiler with "-Os"
> optimize-level you and your binaries/libs get confused.
> Arnd Bergmann sent a patch for these "false-positives" (use
> "-Wmaybe-uninitialized" as a CFLAGS).
> I think this is a good idea.
> If more kernel-developers ACK it, it might get mainline :-)?
> Gogogo johill (but don't runaway) :-)...
>
> For more details see also gcc-docs on how to suppress errors and treat
> them as warnings [1].
>
> Regards,
> - Sedat -
>
> [1] http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-Options
>

Uuurgh, forgot to add the link for Arnd's patch....

- Sedat -

[2] https://patchwork.kernel.org/patch/2274041/

>> johannes
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Arnd Bergmann March 28, 2013, 11:32 a.m. UTC | #4
On Thursday 28 March 2013, Sedat Dilek wrote:
> On Thu, Mar 28, 2013 at 12:28 PM, Sedat Dilek <sedat.dilek@gmail.com> wrote:
> 
> [2] https://patchwork.kernel.org/patch/2274041/
>

There is a newer version with an updated description here:

https://patchwork.kernel.org/patch/2332071/

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vincent Stehlé March 30, 2013, 3:17 p.m. UTC | #5
On 03/28/2013 10:21 AM, Johannes Berg wrote:
> No, you're wrong, presumably misled by the compiler.

Ah! Right; I see it now. Sorry for the noise.

V.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 8914d2d..57a5722 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1777,7 +1777,7 @@  netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
 	bool multicast;
 	u32 info_flags = 0;
 	u16 info_id = 0;
-	struct ieee80211_chanctx_conf *chanctx_conf;
+	struct ieee80211_chanctx_conf *chanctx_conf = NULL;
 	struct ieee80211_sub_if_data *ap_sdata;
 	enum ieee80211_band band;