From: Marcel Holtmann <marcel@holtmann.org>
To: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Stephen Hemminger <shemminger@vyatta.com>,
vibi_sreenivasan@cms.com, netdev <netdev@vger.kernel.org>,
Johannes Berg <johannes@sipsolutions.net>,
Thomas Graf <tgraf@suug.ch>,
linux-next <linux-next@vger.kernel.org>
Subject: Re: [PATCH] Fix Warnings from net/netlink/genetlink.c
Date: Tue, 11 Aug 2009 21:03:55 -0700 [thread overview]
Message-ID: <1250049835.30166.47.camel@localhost.localdomain> (raw)
In-Reply-To: <20090812135031.a38be3f6.sfr@canb.auug.org.au>
Hi Stephen,
> > > > @@ -136,7 +136,7 @@ int genl_register_mc_group(struct genl_family *family,
> > > > {
> > > > int id;
> > > > unsigned long *new_groups;
> > > > - int err;
> > > > + int err = 0;
> > > >
> > > > BUG_ON(grp->name[0] == '\0');
> > >
> > > this looks fishy. How does gcc thinks this variable is uninitialized. If
> > > I look at the code in Linus' tree, I don't see it.
> >
> > Agreed, and the line numbers are off.
>
> In the -next tree, it looks like this:
it would have been nice if the patch actually indicates that it is for
-next since otherwise just shutting up a compiler warning is a bad idea
in this case.
> int genl_register_mc_group(struct genl_family *family,
> struct genl_multicast_group *grp)
> {
> int id;
> unsigned long *new_groups;
> int err;
>
> BUG_ON(grp->name[0] == '\0');
>
> genl_lock();
>
> /* special-case our own group */
> if (grp == ¬ify_grp)
> id = GENL_ID_CTRL;
> else
> id = find_first_zero_bit(mc_groups,
> mc_groups_longs * BITS_PER_LONG);
>
>
> if (id >= mc_groups_longs * BITS_PER_LONG) {
> size_t nlen = (mc_groups_longs + 1) * sizeof(unsigned long);
>
> if (mc_groups == &mc_group_start) {
> new_groups = kzalloc(nlen, GFP_KERNEL);
> if (!new_groups) {
> err = -ENOMEM;
> goto out;
> }
> mc_groups = new_groups;
> *mc_groups = mc_group_start;
> } else {
> new_groups = krealloc(mc_groups, nlen, GFP_KERNEL);
> if (!new_groups) {
> err = -ENOMEM;
> goto out;
> }
> mc_groups = new_groups;
> mc_groups[mc_groups_longs] = 0;
> }
> mc_groups_longs++;
> }
>
> if (family->netnsok) {
> struct net *net;
>
> rcu_read_lock();
> for_each_net_rcu(net) {
> err = netlink_change_ngroups(net->genl_sock,
> mc_groups_longs * BITS_PER_LONG);
> if (err) {
> rcu_read_unlock();
> goto out;
> }
> }
> rcu_read_unlock();
> } else {
> err = netlink_change_ngroups(init_net.genl_sock,
> mc_groups_longs * BITS_PER_LONG);
> if (err)
> goto out;
> }
>
> grp->id = id;
> set_bit(id, mc_groups);
> list_add_tail(&grp->list, &family->mcast_groups);
> grp->family = family;
>
> genl_ctrl_event(CTRL_CMD_NEWMCAST_GRP, grp);
> out:
> genl_unlock();
> return err;
> }
>
> so if family->netnsok is true and the for_each_net_rcu loop executes 0
> times, err will not be set ... Now, that may not be logically possible,
> but I can't tell that from this code.
I prefer we add a err = 0 in the if (family->netnsok) { block instead of
just globally setting it to a value.
Regards
Marcel
next prev parent reply other threads:[~2009-08-12 4:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-11 10:07 [PATCH] Fix Warnings from net/netlink/genetlink.c vibi sreenivasan
2009-08-11 23:57 ` Marcel Holtmann
2009-08-12 3:24 ` Stephen Hemminger
2009-08-12 3:50 ` Stephen Rothwell
2009-08-12 4:03 ` Marcel Holtmann [this message]
[not found] <1249975630.2400.7.camel@HunTEr>
2009-08-11 7:36 ` Johannes Berg
2009-08-11 9:15 ` vibi sreenivasan
2009-08-11 9:11 ` Johannes Berg
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=1250049835.30166.47.camel@localhost.localdomain \
--to=marcel@holtmann.org \
--cc=johannes@sipsolutions.net \
--cc=linux-next@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sfr@canb.auug.org.au \
--cc=shemminger@vyatta.com \
--cc=tgraf@suug.ch \
--cc=vibi_sreenivasan@cms.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 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).