2013-03-28 09:18:44

by Vincent Stehlé

[permalink] [raw]
Subject: [PATCH] mac80211: fix uninitialized variable

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é <[email protected]>
Cc: Johannes Berg <[email protected]>
---
net/mac80211/tx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

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;

--
1.7.10.4



2013-03-28 11:30:58

by Sedat Dilek

[permalink] [raw]
Subject: Re: [PATCH] mac80211: fix uninitialized variable

On Thu, Mar 28, 2013 at 12:28 PM, Sedat Dilek <[email protected]> wrote:
> On Thu, Mar 28, 2013 at 10:21 AM, Johannes Berg
> <[email protected]> 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 [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html

2013-03-28 09:23:54

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] mac80211: fix uninitialized variable

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


2013-03-28 11:32:44

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH] mac80211: fix uninitialized variable

On Thursday 28 March 2013, Sedat Dilek wrote:
> On Thu, Mar 28, 2013 at 12:28 PM, Sedat Dilek <[email protected]> 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

2013-03-30 15:17:22

by Vincent Stehlé

[permalink] [raw]
Subject: Re: [PATCH] mac80211: fix uninitialized variable

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.

2013-03-28 11:28:51

by Sedat Dilek

[permalink] [raw]
Subject: Re: [PATCH] mac80211: fix uninitialized variable

On Thu, Mar 28, 2013 at 10:21 AM, Johannes Berg
<[email protected]> 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 [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2013-10-21 10:26:08

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] mac80211: fix uninitialized variable

On Fri, 2013-10-18 at 14:57 -0700, Michal Kazior wrote:
> CSA completion could call in a driver
> bss_info_changed() with a garbled `changed` flag
> leading to all sorts of problems.

Applied.

johannes