Skip to content

Commit

Permalink
pkt_sched: Add BH protection for qdisc_stab_lock.
Browse files Browse the repository at this point in the history
Since qdisc_stab_lock is used in qdisc_put_stab(), which is called in
BH context from __qdisc_destroy() RCU callback, softirq safe locking
is needed.

Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jarek Poplawski authored and David S. Miller committed Aug 12, 2008
1 parent 0a37c10 commit 1cfa266
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions net/sched/sch_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,19 +331,19 @@ static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt)
if (!s || tsize != s->tsize || (!tab && tsize > 0))
return ERR_PTR(-EINVAL);

spin_lock(&qdisc_stab_lock);
spin_lock_bh(&qdisc_stab_lock);

list_for_each_entry(stab, &qdisc_stab_list, list) {
if (memcmp(&stab->szopts, s, sizeof(*s)))
continue;
if (tsize > 0 && memcmp(stab->data, tab, tsize * sizeof(u16)))
continue;
stab->refcnt++;
spin_unlock(&qdisc_stab_lock);
spin_unlock_bh(&qdisc_stab_lock);
return stab;
}

spin_unlock(&qdisc_stab_lock);
spin_unlock_bh(&qdisc_stab_lock);

stab = kmalloc(sizeof(*stab) + tsize * sizeof(u16), GFP_KERNEL);
if (!stab)
Expand All @@ -354,9 +354,9 @@ static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt)
if (tsize > 0)
memcpy(stab->data, tab, tsize * sizeof(u16));

spin_lock(&qdisc_stab_lock);
spin_lock_bh(&qdisc_stab_lock);
list_add_tail(&stab->list, &qdisc_stab_list);
spin_unlock(&qdisc_stab_lock);
spin_unlock_bh(&qdisc_stab_lock);

return stab;
}
Expand All @@ -366,14 +366,14 @@ void qdisc_put_stab(struct qdisc_size_table *tab)
if (!tab)
return;

spin_lock(&qdisc_stab_lock);
spin_lock_bh(&qdisc_stab_lock);

if (--tab->refcnt == 0) {
list_del(&tab->list);
kfree(tab);
}

spin_unlock(&qdisc_stab_lock);
spin_unlock_bh(&qdisc_stab_lock);
}
EXPORT_SYMBOL(qdisc_put_stab);

Expand Down

0 comments on commit 1cfa266

Please sign in to comment.