* [PATCH] [RFC] net: dsa: mv88e6xxx: Pre-initialize err in mv88e6xxx_port_bridge_join()
@ 2016-04-25 7:52 Geert Uytterhoeven
2016-04-25 15:03 ` Vivien Didelot
0 siblings, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2016-04-25 7:52 UTC (permalink / raw)
To: David S. Miller, Vivien Didelot; +Cc: netdev, linux-kernel, Geert Uytterhoeven
drivers/net/dsa/mv88e6xxx.c: In function ‘mv88e6xxx_port_bridge_join’:
drivers/net/dsa/mv88e6xxx.c:2184: warning: ‘err’ may be used uninitialized in this function
If netdev_notifier_changeupper_info.upper_dev is ever NULL, the bridge
parameter will be NULL too, and the function will return an
uninitialized value.
Pre-initialize err to zero to fix this.
Fixes: 207afda1b5036009 ("net: dsa: mv88e6xxx: share the same default FDB")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Can this actually happen?
---
drivers/net/dsa/mv88e6xxx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index a2904029cccc2949..5e572b3510b9483a 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -2181,7 +2181,7 @@ int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
struct net_device *bridge)
{
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
- int i, err;
+ int i, err = 0;
mutex_lock(&ps->smi_mutex);
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] [RFC] net: dsa: mv88e6xxx: Pre-initialize err in mv88e6xxx_port_bridge_join()
2016-04-25 7:52 [PATCH] [RFC] net: dsa: mv88e6xxx: Pre-initialize err in mv88e6xxx_port_bridge_join() Geert Uytterhoeven
@ 2016-04-25 15:03 ` Vivien Didelot
2016-04-25 16:34 ` Geert Uytterhoeven
0 siblings, 1 reply; 6+ messages in thread
From: Vivien Didelot @ 2016-04-25 15:03 UTC (permalink / raw)
To: Geert Uytterhoeven, David S. Miller
Cc: netdev, linux-kernel, Geert Uytterhoeven
Hi Geert,
Geert Uytterhoeven <geert@linux-m68k.org> writes:
> drivers/net/dsa/mv88e6xxx.c: In function ‘mv88e6xxx_port_bridge_join’:
> drivers/net/dsa/mv88e6xxx.c:2184: warning: ‘err’ may be used uninitialized in this function
Interesting, I don't have those warnings on 207afda1b5036009...
> If netdev_notifier_changeupper_info.upper_dev is ever NULL, the bridge
> parameter will be NULL too, and the function will return an
> uninitialized value.
>
> Pre-initialize err to zero to fix this.
>
> Fixes: 207afda1b5036009 ("net: dsa: mv88e6xxx: share the same default FDB")
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> Can this actually happen?
bridge cannot be NULL here. Also ps->ports[port].bridge_dev is assigned
to it before entering the for loop, so _mv88e6xxx_port_based_vlan_map
will be called at least for this port.
Thanks,
Vivien
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [RFC] net: dsa: mv88e6xxx: Pre-initialize err in mv88e6xxx_port_bridge_join()
2016-04-25 15:03 ` Vivien Didelot
@ 2016-04-25 16:34 ` Geert Uytterhoeven
2016-04-25 17:31 ` Vivien Didelot
0 siblings, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2016-04-25 16:34 UTC (permalink / raw)
To: Vivien Didelot
Cc: David S. Miller, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Hi Vivien,
On Mon, Apr 25, 2016 at 5:03 PM, Vivien Didelot
<vivien.didelot@savoirfairelinux.com> wrote:
> Geert Uytterhoeven <geert@linux-m68k.org> writes:
>> drivers/net/dsa/mv88e6xxx.c: In function ‘mv88e6xxx_port_bridge_join’:
>> drivers/net/dsa/mv88e6xxx.c:2184: warning: ‘err’ may be used uninitialized in this function
>
> Interesting, I don't have those warnings on 207afda1b5036009...
It depends on the compiler version (still using 4.1.2) and options.
>> If netdev_notifier_changeupper_info.upper_dev is ever NULL, the bridge
>> parameter will be NULL too, and the function will return an
>> uninitialized value.
>>
>> Pre-initialize err to zero to fix this.
>>
>> Fixes: 207afda1b5036009 ("net: dsa: mv88e6xxx: share the same default FDB")
>> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
>> ---
>> Can this actually happen?
>
> bridge cannot be NULL here. Also ps->ports[port].bridge_dev is assigned
> to it before entering the for loop, so _mv88e6xxx_port_based_vlan_map
> will be called at least for this port.
But there's no way the compiler can know that...
Gr{oetje,eeting}s,
Geert
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [RFC] net: dsa: mv88e6xxx: Pre-initialize err in mv88e6xxx_port_bridge_join()
2016-04-25 16:34 ` Geert Uytterhoeven
@ 2016-04-25 17:31 ` Vivien Didelot
2016-04-25 17:53 ` Geert Uytterhoeven
0 siblings, 1 reply; 6+ messages in thread
From: Vivien Didelot @ 2016-04-25 17:31 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: David S. Miller, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Hi Geert,
Geert Uytterhoeven <geert@linux-m68k.org> writes:
> On Mon, Apr 25, 2016 at 5:03 PM, Vivien Didelot
> <vivien.didelot@savoirfairelinux.com> wrote:
>> Geert Uytterhoeven <geert@linux-m68k.org> writes:
>>> drivers/net/dsa/mv88e6xxx.c: In function ‘mv88e6xxx_port_bridge_join’:
>>> drivers/net/dsa/mv88e6xxx.c:2184: warning: ‘err’ may be used uninitialized in this function
>>
>> Interesting, I don't have those warnings on 207afda1b5036009...
>
> It depends on the compiler version (still using 4.1.2) and options.
>
>>> If netdev_notifier_changeupper_info.upper_dev is ever NULL, the bridge
>>> parameter will be NULL too, and the function will return an
>>> uninitialized value.
>>>
>>> Pre-initialize err to zero to fix this.
>>>
>>> Fixes: 207afda1b5036009 ("net: dsa: mv88e6xxx: share the same default FDB")
>>> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
>>> ---
>>> Can this actually happen?
>>
>> bridge cannot be NULL here. Also ps->ports[port].bridge_dev is assigned
>> to it before entering the for loop, so _mv88e6xxx_port_based_vlan_map
>> will be called at least for this port.
>
> But there's no way the compiler can know that...
Or maybe it can in new configurations. Anyway, this fix doesn't hurt,
with a relevant commit message, I'd ack it.
Thanks,
Vivien
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [RFC] net: dsa: mv88e6xxx: Pre-initialize err in mv88e6xxx_port_bridge_join()
2016-04-25 17:31 ` Vivien Didelot
@ 2016-04-25 17:53 ` Geert Uytterhoeven
2016-04-25 18:35 ` Vivien Didelot
0 siblings, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2016-04-25 17:53 UTC (permalink / raw)
To: Vivien Didelot
Cc: David S. Miller, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Hi Vivien,
On Mon, Apr 25, 2016 at 7:31 PM, Vivien Didelot
<vivien.didelot@savoirfairelinux.com> wrote:
> Geert Uytterhoeven <geert@linux-m68k.org> writes:
>> On Mon, Apr 25, 2016 at 5:03 PM, Vivien Didelot
>> <vivien.didelot@savoirfairelinux.com> wrote:
>>> Geert Uytterhoeven <geert@linux-m68k.org> writes:
>>>> drivers/net/dsa/mv88e6xxx.c: In function ‘mv88e6xxx_port_bridge_join’:
>>>> drivers/net/dsa/mv88e6xxx.c:2184: warning: ‘err’ may be used uninitialized in this function
>>>
>>> Interesting, I don't have those warnings on 207afda1b5036009...
>>
>> It depends on the compiler version (still using 4.1.2) and options.
>>
>>>> If netdev_notifier_changeupper_info.upper_dev is ever NULL, the bridge
>>>> parameter will be NULL too, and the function will return an
>>>> uninitialized value.
>>>>
>>>> Pre-initialize err to zero to fix this.
>>>>
>>>> Fixes: 207afda1b5036009 ("net: dsa: mv88e6xxx: share the same default FDB")
>>>> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
>>>> ---
>>>> Can this actually happen?
>>>
>>> bridge cannot be NULL here. Also ps->ports[port].bridge_dev is assigned
>>> to it before entering the for loop, so _mv88e6xxx_port_based_vlan_map
>>> will be called at least for this port.
>>
>> But there's no way the compiler can know that...
>
> Or maybe it can in new configurations. Anyway, this fix doesn't hurt,
> with a relevant commit message, I'd ack it.
What would you consider a relevant commit message?
Thanks!
Gr{oetje,eeting}s,
Geert
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [RFC] net: dsa: mv88e6xxx: Pre-initialize err in mv88e6xxx_port_bridge_join()
2016-04-25 17:53 ` Geert Uytterhoeven
@ 2016-04-25 18:35 ` Vivien Didelot
0 siblings, 0 replies; 6+ messages in thread
From: Vivien Didelot @ 2016-04-25 18:35 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: David S. Miller, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Hi Geert,
Geert Uytterhoeven <geert@linux-m68k.org> writes:
> Hi Vivien,
>
> On Mon, Apr 25, 2016 at 7:31 PM, Vivien Didelot
> <vivien.didelot@savoirfairelinux.com> wrote:
>> Geert Uytterhoeven <geert@linux-m68k.org> writes:
>>> On Mon, Apr 25, 2016 at 5:03 PM, Vivien Didelot
>>> <vivien.didelot@savoirfairelinux.com> wrote:
>>>> Geert Uytterhoeven <geert@linux-m68k.org> writes:
>>>>> drivers/net/dsa/mv88e6xxx.c: In function ‘mv88e6xxx_port_bridge_join’:
>>>>> drivers/net/dsa/mv88e6xxx.c:2184: warning: ‘err’ may be used uninitialized in this function
>>>>
>>>> Interesting, I don't have those warnings on 207afda1b5036009...
>>>
>>> It depends on the compiler version (still using 4.1.2) and options.
>>>
>>>>> If netdev_notifier_changeupper_info.upper_dev is ever NULL, the bridge
>>>>> parameter will be NULL too, and the function will return an
>>>>> uninitialized value.
>>>>>
>>>>> Pre-initialize err to zero to fix this.
>>>>>
>>>>> Fixes: 207afda1b5036009 ("net: dsa: mv88e6xxx: share the same default FDB")
>>>>> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
>>>>> ---
>>>>> Can this actually happen?
>>>>
>>>> bridge cannot be NULL here. Also ps->ports[port].bridge_dev is assigned
>>>> to it before entering the for loop, so _mv88e6xxx_port_based_vlan_map
>>>> will be called at least for this port.
>>>
>>> But there's no way the compiler can know that...
>>
>> Or maybe it can in new configurations. Anyway, this fix doesn't hurt,
>> with a relevant commit message, I'd ack it.
>
> What would you consider a relevant commit message?
bridge being NULL is not the reason why err can eventually get returned
uninitialized. The GCC version would be great too, I have no such
warning here with 5.3.0.
Thanks,
-v
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-04-25 18:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-25 7:52 [PATCH] [RFC] net: dsa: mv88e6xxx: Pre-initialize err in mv88e6xxx_port_bridge_join() Geert Uytterhoeven
2016-04-25 15:03 ` Vivien Didelot
2016-04-25 16:34 ` Geert Uytterhoeven
2016-04-25 17:31 ` Vivien Didelot
2016-04-25 17:53 ` Geert Uytterhoeven
2016-04-25 18:35 ` Vivien Didelot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).