diff mbox

net.git: Call-trace after "Merge branch 'netlink_multicast'"

Message ID 20141229.163311.498586171360350188.davem@davemloft.net
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

David Miller Dec. 29, 2014, 9:33 p.m. UTC
From: Sedat Dilek <sedat.dilek@gmail.com>
Date: Sun, 28 Dec 2014 10:34:51 +0100

> On Sun, Dec 28, 2014 at 8:54 AM, Sedat Dilek <sedat.dilek@gmail.com> wrote:
>> Just a small thing, if you look at this...
>>
>> With gcc-4.9.2 I see this warning in my logs...
>>
>> net/netlink/genetlink.c: In function 'genl_bind':
>> net/netlink/genetlink.c:1018:2: warning: 'err' may be used
>> uninitialized in this function [-Wmaybe-uninitialized]
>>
> 
> Attached patch fixes the issue for me.

Ok since the user can request arbitrary multicast groups, we cannot
warn in this situation.

And since initializing 'err' to zero makes the whole 'found'
variable completely unnecessary, we can delete that too.

This is the final patch I am applying, thanks for all of your
help.

Comments

Sedat Dilek Dec. 31, 2014, 1:17 p.m. UTC | #1
On Mon, Dec 29, 2014 at 10:33 PM, David Miller <davem@davemloft.net> wrote:
> From: Sedat Dilek <sedat.dilek@gmail.com>
> Date: Sun, 28 Dec 2014 10:34:51 +0100
>
>> On Sun, Dec 28, 2014 at 8:54 AM, Sedat Dilek <sedat.dilek@gmail.com> wrote:
>>> Just a small thing, if you look at this...
>>>
>>> With gcc-4.9.2 I see this warning in my logs...
>>>
>>> net/netlink/genetlink.c: In function 'genl_bind':
>>> net/netlink/genetlink.c:1018:2: warning: 'err' may be used
>>> uninitialized in this function [-Wmaybe-uninitialized]
>>>
>>
>> Attached patch fixes the issue for me.
>
> Ok since the user can request arbitrary multicast groups, we cannot
> warn in this situation.
>
> And since initializing 'err' to zero makes the whole 'found'
> variable completely unnecessary, we can delete that too.
>
> This is the final patch I am applying, thanks for all of your
> help.
>
> ====================
> [PATCH] genetlink: A genl_bind() to an out-of-range multicast group should not WARN().
>
> Users can request to bind to arbitrary multicast groups, so warning
> when the requested group number is out of range is not appropriate.
>
> And with the warning removed, and the 'err' variable properly given
> an initial value, we can remove 'found' altogether.
>
> Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
> Signed-off-by: David S. Miller <davem@davemloft.net>

Thanks Dave for pushing this!

Guten Rutsch (Happy new year),
- Sedat -

> ---
>  net/netlink/genetlink.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
> index 91566ed..2e11061 100644
> --- a/net/netlink/genetlink.c
> +++ b/net/netlink/genetlink.c
> @@ -985,8 +985,7 @@ static struct genl_multicast_group genl_ctrl_groups[] = {
>
>  static int genl_bind(struct net *net, int group)
>  {
> -       int i, err;
> -       bool found = false;
> +       int i, err = 0;
>
>         down_read(&cb_lock);
>         for (i = 0; i < GENL_FAM_TAB_SIZE; i++) {
> @@ -1003,16 +1002,12 @@ static int genl_bind(struct net *net, int group)
>                                         err = f->mcast_bind(net, fam_grp);
>                                 else
>                                         err = 0;
> -                               found = true;
>                                 break;
>                         }
>                 }
>         }
>         up_read(&cb_lock);
>
> -       if (WARN_ON(!found))
> -               err = 0;
> -
>         return err;
>  }
>
> --
> 1.7.11.7
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

====================
[PATCH] genetlink: A genl_bind() to an out-of-range multicast group should not WARN().

Users can request to bind to arbitrary multicast groups, so warning
when the requested group number is out of range is not appropriate.

And with the warning removed, and the 'err' variable properly given
an initial value, we can remove 'found' altogether.

Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
 net/netlink/genetlink.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 91566ed..2e11061 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -985,8 +985,7 @@  static struct genl_multicast_group genl_ctrl_groups[] = {
 
 static int genl_bind(struct net *net, int group)
 {
-	int i, err;
-	bool found = false;
+	int i, err = 0;
 
 	down_read(&cb_lock);
 	for (i = 0; i < GENL_FAM_TAB_SIZE; i++) {
@@ -1003,16 +1002,12 @@  static int genl_bind(struct net *net, int group)
 					err = f->mcast_bind(net, fam_grp);
 				else
 					err = 0;
-				found = true;
 				break;
 			}
 		}
 	}
 	up_read(&cb_lock);
 
-	if (WARN_ON(!found))
-		err = 0;
-
 	return err;
 }