From: Cong Wang <amwang@redhat.com>
To: netdev@vger.kernel.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
"David S. Miller" <davem@davemloft.net>,
Cong Wang <amwang@redhat.com>
Subject: [Patch net-next v1 2/3] igmp: fix return values of some functions
Date: Wed, 5 Jun 2013 11:33:30 +0800 [thread overview]
Message-ID: <1370403211-6851-2-git-send-email-amwang@redhat.com> (raw)
In-Reply-To: <1370403211-6851-1-git-send-email-amwang@redhat.com>
From: Cong Wang <amwang@redhat.com>
There are some places casting the return value to void, actually
they can respect the return value.
And ip_mc_leave_src() can become void, because even if it fails,
the operations after it can still continue.
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>
---
net/ipv4/igmp.c | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index d3218c0..e05b571 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1834,24 +1834,23 @@ done:
}
EXPORT_SYMBOL(ip_mc_join_group);
-static int ip_mc_leave_src(struct sock *sk, struct ip_mc_socklist *iml,
+static void ip_mc_leave_src(struct sock *sk, struct ip_mc_socklist *iml,
struct in_device *in_dev)
{
struct ip_sf_socklist *psf = rtnl_dereference(iml->sflist);
- int err;
if (psf == NULL) {
/* any-source empty exclude case */
- return ip_mc_del_src(in_dev, &iml->multi.imr_multiaddr.s_addr,
+ ip_mc_del_src(in_dev, &iml->multi.imr_multiaddr.s_addr,
iml->sfmode, 0, NULL, 0);
+ return;
}
- err = ip_mc_del_src(in_dev, &iml->multi.imr_multiaddr.s_addr,
+ ip_mc_del_src(in_dev, &iml->multi.imr_multiaddr.s_addr,
iml->sfmode, psf->sl_count, psf->sl_addr, 0);
RCU_INIT_POINTER(iml->sflist, NULL);
/* decrease mem now to avoid the memleak warning */
atomic_sub(IP_SFLSIZE(psf->sl_max), &sk->sk_omem_alloc);
kfree_rcu(psf, rcu);
- return err;
}
/*
@@ -1884,7 +1883,7 @@ int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr)
iml->multi.imr_address.s_addr)
continue;
- (void) ip_mc_leave_src(sk, iml, in_dev);
+ ip_mc_leave_src(sk, iml, in_dev);
*imlp = iml->next_rcu;
@@ -1896,6 +1895,7 @@ int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr)
kfree_rcu(iml, rcu);
return 0;
}
+
if (!in_dev)
ret = -ENODEV;
rtnl_unlock();
@@ -2027,10 +2027,9 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
psl->sl_addr[j+1] = psl->sl_addr[j];
psl->sl_addr[i] = mreqs->imr_sourceaddr;
psl->sl_count++;
- err = 0;
/* update the interface list */
- ip_mc_add_src(in_dev, &mreqs->imr_multiaddr, omode, 1,
- &mreqs->imr_sourceaddr, 1);
+ err = ip_mc_add_src(in_dev, &mreqs->imr_multiaddr, omode, 1,
+ &mreqs->imr_sourceaddr, 1);
done:
rtnl_unlock();
if (leavegroup)
@@ -2097,22 +2096,23 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex)
}
} else {
newpsl = NULL;
- (void) ip_mc_add_src(in_dev, &msf->imsf_multiaddr,
+ err = ip_mc_add_src(in_dev, &msf->imsf_multiaddr,
msf->imsf_fmode, 0, NULL, 0);
+ if (err)
+ goto done;
}
psl = rtnl_dereference(pmc->sflist);
if (psl) {
- (void) ip_mc_del_src(in_dev, &msf->imsf_multiaddr, pmc->sfmode,
+ err = ip_mc_del_src(in_dev, &msf->imsf_multiaddr, pmc->sfmode,
psl->sl_count, psl->sl_addr, 0);
/* decrease mem now to avoid the memleak warning */
atomic_sub(IP_SFLSIZE(psl->sl_max), &sk->sk_omem_alloc);
kfree_rcu(psl, rcu);
} else
- (void) ip_mc_del_src(in_dev, &msf->imsf_multiaddr, pmc->sfmode,
+ err = ip_mc_del_src(in_dev, &msf->imsf_multiaddr, pmc->sfmode,
0, NULL, 0);
rcu_assign_pointer(pmc->sflist, newpsl);
pmc->sfmode = msf->imsf_fmode;
- err = 0;
done:
rtnl_unlock();
if (leavegroup)
@@ -2295,7 +2295,7 @@ void ip_mc_drop_socket(struct sock *sk)
inet->mc_list = iml->next_rcu;
in_dev = inetdev_by_index(net, iml->multi.imr_ifindex);
- (void) ip_mc_leave_src(sk, iml, in_dev);
+ ip_mc_leave_src(sk, iml, in_dev);
if (in_dev != NULL)
ip_mc_dec_group(in_dev, iml->multi.imr_multiaddr.s_addr);
/* decrease mem now to avoid the memleak warning */
--
1.7.7.6
next prev parent reply other threads:[~2013-06-05 3:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-05 3:33 [Patch net-next v1 1/3] igmp: avoid taking RTNL for ip_mc_find_dev() Cong Wang
2013-06-05 3:33 ` Cong Wang [this message]
2013-06-05 3:33 ` [Patch net-next v1 3/3] igmp: convert RTNL lock to a spinlock Cong Wang
2013-06-05 3:52 ` Stephen Hemminger
2013-06-05 5:21 ` Cong Wang
2013-06-05 5:32 ` Cong Wang
2013-06-05 4:07 ` [Patch net-next v1 1/3] igmp: avoid taking RTNL for ip_mc_find_dev() Eric Dumazet
2013-06-05 5:23 ` Cong Wang
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=1370403211-6851-2-git-send-email-amwang@redhat.com \
--to=amwang@redhat.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/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).