Skip to content

Commit cbdf451

Browse files
edumazetdavem330
authored andcommitted
net_sched: prio: properly report out of memory errors
At Qdisc creation or change time, prio_tune() creates missing pfifo qdiscs but does not return an error code if one qdisc could not be allocated. Leaving a qdisc in non operational state without telling user anything about this problem is not good. Also, testing if we replace something different than noop_qdisc a second time makes no sense so I removed useless code. Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 86ef7f9 commit cbdf451

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

net/sched/sch_prio.c

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -202,26 +202,18 @@ static int prio_tune(struct Qdisc *sch, struct nlattr *opt)
202202
sch_tree_unlock(sch);
203203

204204
for (i = 0; i < q->bands; i++) {
205-
if (q->queues[i] == &noop_qdisc) {
206-
struct Qdisc *child, *old;
207-
208-
child = qdisc_create_dflt(sch->dev_queue,
209-
&pfifo_qdisc_ops,
210-
TC_H_MAKE(sch->handle, i + 1));
211-
if (child) {
212-
sch_tree_lock(sch);
213-
old = q->queues[i];
214-
q->queues[i] = child;
215-
216-
if (old != &noop_qdisc) {
217-
qdisc_tree_reduce_backlog(old,
218-
old->q.qlen,
219-
old->qstats.backlog);
220-
qdisc_destroy(old);
221-
}
222-
sch_tree_unlock(sch);
223-
}
224-
}
205+
struct Qdisc *child;
206+
207+
if (q->queues[i] != &noop_qdisc)
208+
continue;
209+
210+
child = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops,
211+
TC_H_MAKE(sch->handle, i + 1));
212+
if (!child)
213+
return -ENOMEM;
214+
sch_tree_lock(sch);
215+
q->queues[i] = child;
216+
sch_tree_unlock(sch);
225217
}
226218
return 0;
227219
}

0 commit comments

Comments
 (0)