Skip to contentSkip to conversation

sched: Avoid NULL pointer in the function, qdisc_get_rtab

PATCH Jamal Hadi Salim 1 participant 2 messages May 26, 2015 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 7 lines · Nicholas Krause
net/sched/sch_api.c +0 -0
index ad9eed7..44a8995 100644

net/sched/sch_api.c struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, struct nlattr *ta · line 406

Quoted 8 lines
net/sched/sch_api.c +1 -1
@@ -400,7 +400,7 @@ struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, struct nlattr *ta
  	}
 
  	rtab = kmalloc(sizeof(*rtab), GFP_KERNEL);
-	if (rtab) {
+	if (!rtab) {
  		rtab->rate = *r;
  		rtab->refcnt = 1;
  		memcpy(rtab->data, nla_data(tab), 1024);

Did i miss something so clever it is not obvious? ;-> If rtab's kmalloc fails you want to set rtab's fields? And what is wrong with returning a null rtab again?

cheers,
jamal

#2 lore raw
Quoted 11 lines · Jamal Hadi Salim
Quoted 9 lines · Nicholas Krause
net/sched/sch_api.c +0 -0
index ad9eed7..44a8995 100644
@@ -400,7 +400,7 @@ struct qdisc_rate_table *qdisc_get_rtab(struct

tc_ratespec *r, struct nlattr *ta

      }
Quoted 12 lines

net/sched/sch_api.c

Quoted 7 lines
      rtab = kmalloc(sizeof(*rtab), GFP_KERNEL);
net/sched/sch_api.c +1 -1
-    if (rtab) {
+    if (!rtab) {
          rtab->rate = *r;
          rtab->refcnt = 1;
          memcpy(rtab->data, nla_data(tab), 1024);

Did i miss something so clever it is not obvious? ;-> If rtab's kmalloc fails you want to set rtab's fields? And what is wrong with returning a null rtab again?

Yikes. Seems i fell for some trolling. Hasnt happened since summer of 94. You got me ;->

cheers,
jamal