Skip to content

Commit efb5522

Browse files
vladimirolteandavem330
authored andcommitted
taprio: Fix kernel panic in taprio_destroy
taprio_init may fail earlier than this line: list_add(&q->taprio_list, &taprio_list); i.e. due to the net device not being multi queue. Attempting to remove q from the global taprio_list when it is not part of it will result in a kernel panic. Fix it by matching list_add and list_del better to one another in the order of operations. This way we can keep the deletion unconditional and with lower complexity - O(1). Cc: Leandro Dorileo <[email protected]> Fixes: 7b9eba7 ("net/sched: taprio: fix picos_per_byte miscalculation") Signed-off-by: Vladimir Oltean <[email protected]> Acked-by: Vinicius Costa Gomes <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5f81d54 commit efb5522

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/sched/sch_taprio.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,10 @@ static int taprio_init(struct Qdisc *sch, struct nlattr *opt,
12491249
*/
12501250
q->clockid = -1;
12511251

1252+
spin_lock(&taprio_list_lock);
1253+
list_add(&q->taprio_list, &taprio_list);
1254+
spin_unlock(&taprio_list_lock);
1255+
12521256
if (sch->parent != TC_H_ROOT)
12531257
return -EOPNOTSUPP;
12541258

@@ -1266,10 +1270,6 @@ static int taprio_init(struct Qdisc *sch, struct nlattr *opt,
12661270
if (!opt)
12671271
return -EINVAL;
12681272

1269-
spin_lock(&taprio_list_lock);
1270-
list_add(&q->taprio_list, &taprio_list);
1271-
spin_unlock(&taprio_list_lock);
1272-
12731273
for (i = 0; i < dev->num_tx_queues; i++) {
12741274
struct netdev_queue *dev_queue;
12751275
struct Qdisc *qdisc;

0 commit comments

Comments
 (0)