From: Stephen Hemminger <shemminger@linux-foundation.org>
To: Tobias Klauser <tklauser@distanz.ch>
Cc: "David S. Miller" <davem@davemloft.net>,
bridge@lists.linux-foundation.org, netdev@vger.kernel.org
Subject: Re: [PATCH] bridge: Fix return value of br_multicast_add_group()
Date: Thu, 9 Dec 2010 08:29:24 -0800 [thread overview]
Message-ID: <20101209082924.6d797871@nehalam> (raw)
In-Reply-To: <1291903356-30618-1-git-send-email-tklauser@distanz.ch>
On Thu, 9 Dec 2010 15:02:36 +0100
Tobias Klauser <tklauser@distanz.ch> wrote:
> If br_multicast_new_group returns NULL, we would return 0 (no error) to
> the caller, which is not what we want. Instead we should return -ENOMEM
> in this case.
>
> Also replace IS_ERR(x) || !x by IS_ERR_OR_NULL(x)
>
> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
> ---
> net/bridge/br_multicast.c | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
> index 326e599..d4e1e81 100644
> --- a/net/bridge/br_multicast.c
> +++ b/net/bridge/br_multicast.c
> @@ -713,8 +713,11 @@ static int br_multicast_add_group(struct net_bridge *br,
>
> mp = br_multicast_new_group(br, port, group);
> err = PTR_ERR(mp);
> - if (unlikely(IS_ERR(mp) || !mp))
> + if (IS_ERR_OR_NULL(mp)) {
> + if (!mp)
> + err = -ENOMEM;
> goto err;
> + }
>
> if (!port) {
> hlist_add_head(&mp->mglist, &br->mglist);
I would rather fix br_multicast_new_group so it never returns
NULL. Instead return PTR_ERR(-ENOMEM) on out of memory.
--
next prev parent reply other threads:[~2010-12-09 16:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-09 14:02 [PATCH] bridge: Fix return value of br_multicast_add_group() Tobias Klauser
2010-12-09 16:29 ` Stephen Hemminger [this message]
2010-12-09 18:53 ` Tobias Klauser
2010-12-10 13:18 ` [PATCH v2] bridge: Fix return values of br_multicast_add_group/br_multicast_new_group Tobias Klauser
2010-12-10 21:01 ` David Miller
2010-12-10 22:52 ` Tobias Klauser
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=20101209082924.6d797871@nehalam \
--to=shemminger@linux-foundation.org \
--cc=bridge@lists.linux-foundation.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=tklauser@distanz.ch \
/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).