[PATCH net-next] ipv6: mcast: Remove unnecessary null check in ip6_mc_find_dev()

Yue Haibing posted 1 patch 2 months, 3 weeks ago
net/ipv6/mcast.c | 3 ---
1 file changed, 3 deletions(-)
[PATCH net-next] ipv6: mcast: Remove unnecessary null check in ip6_mc_find_dev()
Posted by Yue Haibing 2 months, 3 weeks ago
These is no need to check null for idev before return NULL.

Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
---
 net/ipv6/mcast.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index e95273ffb2f5..8aecdd85a6ae 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -329,9 +329,6 @@ static struct inet6_dev *ip6_mc_find_dev(struct net *net,
 	idev = in6_dev_get(dev);
 	dev_put(dev);
 
-	if (!idev)
-		return NULL;
-
 	return idev;
 }
 
-- 
2.34.1
Re: [PATCH net-next] ipv6: mcast: Remove unnecessary null check in ip6_mc_find_dev()
Posted by Simon Horman 2 months, 3 weeks ago
+ Iwashima-san

On Mon, Jul 14, 2025 at 04:17:32PM +0800, Yue Haibing wrote:
> These is no need to check null for idev before return NULL.
> 
> Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
> ---
>  net/ipv6/mcast.c | 3 ---
>  1 file changed, 3 deletions(-)

This appears to be a side effect of
commit e6e14d582dd2 ("ipv6: mcast: Don't hold RTNL for MCAST_ socket options.")

I've CCed Iwashimsa-san, who wrote that patch.

But in any case this looks good to me.

Reviewed-by: Simon Horman <horms@kernel.org>

> diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
> index e95273ffb2f5..8aecdd85a6ae 100644
> --- a/net/ipv6/mcast.c
> +++ b/net/ipv6/mcast.c
> @@ -329,9 +329,6 @@ static struct inet6_dev *ip6_mc_find_dev(struct net *net,
>  	idev = in6_dev_get(dev);
>  	dev_put(dev);
>  
> -	if (!idev)
> -		return NULL;
> -
>  	return idev;
>  }
>  
> -- 
> 2.34.1
>
Re: [PATCH net-next] ipv6: mcast: Remove unnecessary null check in ip6_mc_find_dev()
Posted by Kuniyuki Iwashima 2 months, 3 weeks ago
On Mon, Jul 14, 2025 at 5:29 AM Simon Horman <horms@kernel.org> wrote:
>
> + Iwashima-san
>
> On Mon, Jul 14, 2025 at 04:17:32PM +0800, Yue Haibing wrote:
> > These is no need to check null for idev before return NULL.
> >
> > Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
> > ---
> >  net/ipv6/mcast.c | 3 ---
> >  1 file changed, 3 deletions(-)
>
> This appears to be a side effect of
> commit e6e14d582dd2 ("ipv6: mcast: Don't hold RTNL for MCAST_ socket options.")

Exactly :)

Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>

Thank you!

>
> I've CCed Iwashimsa-san, who wrote that patch.
>
> But in any case this looks good to me.
>
> Reviewed-by: Simon Horman <horms@kernel.org>
>
> > diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
> > index e95273ffb2f5..8aecdd85a6ae 100644
> > --- a/net/ipv6/mcast.c
> > +++ b/net/ipv6/mcast.c
> > @@ -329,9 +329,6 @@ static struct inet6_dev *ip6_mc_find_dev(struct net *net,
> >       idev = in6_dev_get(dev);
> >       dev_put(dev);
> >
> > -     if (!idev)
> > -             return NULL;
> > -
> >       return idev;
> >  }
> >
> > --
> > 2.34.1
> >