Skip to contentSkip to conversation

net/sched: remove unneeded NULL check

PATCH Applied Dan Carpenter 3 participants 3 messages Aug 14, 2010 – Aug 18, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/sched: remove unneeded NULL check

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.

net/sched/sch_api.c +1 -1
index 408eea7..6fb3d41 100644
@@ -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);
#1 lore raw
Quoted 3 lines · Dan Carpenter

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.

Quoted 17 lines
net/sched/sch_api.c +1 -2
index 408eea7..6fb3d41 100644
@@ -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);
--