* [PATCH] genetlink: Fix uninitialized variable in genl_validate_assign_mc_groups()
@ 2013-11-23 12:01 Geert Uytterhoeven
2013-11-28 23:25 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2013-11-23 12:01 UTC (permalink / raw)
To: David S. Miller, Johannes Berg; +Cc: netdev, linux-kernel, Geert Uytterhoeven
net/netlink/genetlink.c: In function ‘genl_validate_assign_mc_groups’:
net/netlink/genetlink.c:217: warning: ‘err’ may be used uninitialized in this
function
Commit 2a94fe48f32ccf7321450a2cc07f2b724a444e5b ("genetlink: make multicast
groups const, prevent abuse") split genl_register_mc_group() in multiple
functions, but dropped the initialization of err.
Initialize err to zero to fix this.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Question: Is the for_each_net_rcu() loop in genl_validate_assign_mc_groups()
guaranteed to loop at least once?
If yes, this is a false positive.
net/netlink/genetlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 4518a57aa5fe..803206e82450 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -214,7 +214,7 @@ static int genl_validate_assign_mc_groups(struct genl_family *family)
{
int first_id;
int n_groups = family->n_mcgrps;
- int err, i;
+ int err = 0, i;
bool groups_allocated = false;
if (!n_groups)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] genetlink: Fix uninitialized variable in genl_validate_assign_mc_groups()
2013-11-23 12:01 [PATCH] genetlink: Fix uninitialized variable in genl_validate_assign_mc_groups() Geert Uytterhoeven
@ 2013-11-28 23:25 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2013-11-28 23:25 UTC (permalink / raw)
To: geert; +Cc: johannes.berg, netdev, linux-kernel
From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: Sat, 23 Nov 2013 13:01:50 +0100
> net/netlink/genetlink.c: In function ‘genl_validate_assign_mc_groups’:
> net/netlink/genetlink.c:217: warning: ‘err’ may be used uninitialized in this
> function
>
> Commit 2a94fe48f32ccf7321450a2cc07f2b724a444e5b ("genetlink: make multicast
> groups const, prevent abuse") split genl_register_mc_group() in multiple
> functions, but dropped the initialization of err.
>
> Initialize err to zero to fix this.
>
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> Question: Is the for_each_net_rcu() loop in genl_validate_assign_mc_groups()
> guaranteed to loop at least once?
> If yes, this is a false positive.
Applied, but yes it's a false positive. There is always &init_net so the
loop always iterates at least once.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-11-28 23:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-23 12:01 [PATCH] genetlink: Fix uninitialized variable in genl_validate_assign_mc_groups() Geert Uytterhoeven
2013-11-28 23:25 ` David Miller
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).