Patchwork net/sched: remove unneeded NULL check

login
register
mail settings
Submitter Dan Carpenter
Date Aug. 14, 2010, 9:09 p.m.
Message ID <20100814210949.GB645@bicker>
Download mbox | patch
Permalink /patch/61738/
State Accepted
Delegated to: David Miller
Headers show

Comments

Dan Carpenter - Aug. 14, 2010, 9:09 p.m.
There is no need to check "s".  nla_data() doesn't return NULL.  Also we
already dereferenced "s" at this point so it would have oopsed ealier if
it were NULL.

Signed-off-by: Dan Carpenter <error27@gmail.com>

--
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
Jarek Poplawski - Aug. 16, 2010, 10:14 a.m.
Dan Carpenter wrote:
> There is no need to check "s".  nla_data() doesn't return NULL.  Also we
> already dereferenced "s" at this point so it would have oopsed ealier if
> it were NULL.

Looks OK to me.

Jarek P.

> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
> index 408eea7..6fb3d41 100644
> --- a/net/sched/sch_api.c
> +++ b/net/sched/sch_api.c
> @@ -360,7 +360,7 @@ static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt)
>  		tsize = nla_len(tb[TCA_STAB_DATA]) / sizeof(u16);
>  	}
>  
> -	if (!s || tsize != s->tsize || (!tab && tsize > 0))
> +	if (tsize != s->tsize || (!tab && tsize > 0))
>  		return ERR_PTR(-EINVAL);
>  
>  	spin_lock(&qdisc_stab_lock);
> --
--
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
David Miller - Aug. 18, 2010, 9:27 p.m.
From: Dan Carpenter <error27@gmail.com>
Date: Sat, 14 Aug 2010 23:09:49 +0200

> There is no need to check "s".  nla_data() doesn't return NULL.  Also we
> already dereferenced "s" at this point so it would have oopsed ealier if
> it were NULL.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Applied.
--
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

Patch

diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 408eea7..6fb3d41 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -360,7 +360,7 @@  static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt)
 		tsize = nla_len(tb[TCA_STAB_DATA]) / sizeof(u16);
 	}
 
-	if (!s || tsize != s->tsize || (!tab && tsize > 0))
+	if (tsize != s->tsize || (!tab && tsize > 0))
 		return ERR_PTR(-EINVAL);
 
 	spin_lock(&qdisc_stab_lock);