diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index d8a33486c511..847109dc5fa5 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -342,11 +342,11 @@ static struct Qdisc *qdisc_leaf(struct Qdisc *p, u32 classid) const struct Qdisc_class_ops *cops = p->ops->cl_ops; if (cops == NULL) - return NULL; + return ERR_PTR(-EOPNOTSUPP); cl = cops->find(p, classid); if (cl == 0) - return NULL; + return ERR_PTR(-ENOENT); return cops->leaf(p, cl); } @@ -1497,7 +1497,7 @@ static int __tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n, } else { q = rtnl_dereference(dev->qdisc); } - if (!q) { + if (IS_ERR_OR_NULL(q)) { NL_SET_ERR_MSG(extack, "Cannot find specified qdisc on specified device"); return -ENOENT; } @@ -1602,7 +1602,12 @@ static int __tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n, NL_SET_ERR_MSG(extack, "Failed to find specified qdisc"); return -ENOENT; } + q = qdisc_leaf(p, clid); + if (IS_ERR(q)) { + NL_SET_ERR_MSG(extack, "Specified class not found"); + return PTR_ERR(q); + } } else if (dev_ingress_queue_create(dev)) { q = rtnl_dereference(dev_ingress_queue(dev)->qdisc_sleeping); }