pktgen: Dont leak kernel memory
[safe/jmp/linux-2.6] / net / sched / cls_api.c
index 09cdcdf..7cf6c0f 100644 (file)
@@ -168,8 +168,7 @@ replay:
 
        /* Find qdisc */
        if (!parent) {
-               struct netdev_queue *dev_queue = netdev_get_tx_queue(dev, 0);
-               q = dev_queue->qdisc_sleeping;
+               q = dev->qdisc;
                parent = q->handle;
        } else {
                q = qdisc_lookup(dev, TC_H_MAJ(t->tcm_parent));
@@ -181,6 +180,9 @@ replay:
        if ((cops = q->ops->cl_ops) == NULL)
                return -EINVAL;
 
+       if (cops->tcf_chain == NULL)
+               return -EOPNOTSUPP;
+
        /* Do we search for filter, attached to class? */
        if (TC_H_MIN(parent)) {
                cl = cops->get(q, parent);
@@ -348,7 +350,7 @@ static int tcf_fill_node(struct sk_buff *skb, struct tcf_proto *tp,
        tcm = NLMSG_DATA(nlh);
        tcm->tcm_family = AF_UNSPEC;
        tcm->tcm__pad1 = 0;
-       tcm->tcm__pad1 = 0;
+       tcm->tcm__pad2 = 0;
        tcm->tcm_ifindex = qdisc_dev(tp->q)->ifindex;
        tcm->tcm_parent = tp->classid;
        tcm->tcm_info = TC_H_MAKE(tp->prio, tp->protocol);
@@ -405,7 +407,6 @@ static int tcf_node_dump(struct tcf_proto *tp, unsigned long n,
 static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
 {
        struct net *net = sock_net(skb->sk);
-       struct netdev_queue *dev_queue;
        int t;
        int s_t;
        struct net_device *dev;
@@ -424,15 +425,16 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
        if ((dev = dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL)
                return skb->len;
 
-       dev_queue = netdev_get_tx_queue(dev, 0);
        if (!tcm->tcm_parent)
-               q = dev_queue->qdisc_sleeping;
+               q = dev->qdisc;
        else
                q = qdisc_lookup(dev, TC_H_MAJ(tcm->tcm_parent));
        if (!q)
                goto out;
        if ((cops = q->ops->cl_ops) == NULL)
                goto errout;
+       if (cops->tcf_chain == NULL)
+               goto errout;
        if (TC_H_MIN(tcm->tcm_parent)) {
                cl = cops->get(q, tcm->tcm_parent);
                if (cl == 0)