Skip to content

Commit 26aa045

Browse files
Jesus Sanchez-PalenciaJeff Kirsher
authored andcommitted
net/sched: Check for null dev_queue on create flow
In qdisc_alloc() the dev_queue pointer was used without any checks being performed. If qdisc_create() gets a null dev_queue pointer, it just passes it along to qdisc_alloc(), leading to a crash. That happens if a root qdisc implements select_queue() and returns a null dev_queue pointer for an "invalid handle", for example, or if the dev_queue associated with the parent qdisc is null. This patch is in preparation for the next in this series, where select_queue() is being added to mqprio and as it may return a null dev_queue. Signed-off-by: Jesus Sanchez-Palencia <[email protected]> Tested-by: Henrik Austad <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent c859e21 commit 26aa045

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

net/sched/sch_generic.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,14 @@ struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
603603
struct Qdisc *sch;
604604
unsigned int size = QDISC_ALIGN(sizeof(*sch)) + ops->priv_size;
605605
int err = -ENOBUFS;
606-
struct net_device *dev = dev_queue->dev;
606+
struct net_device *dev;
607+
608+
if (!dev_queue) {
609+
err = -EINVAL;
610+
goto errout;
611+
}
607612

613+
dev = dev_queue->dev;
608614
p = kzalloc_node(size, GFP_KERNEL,
609615
netdev_queue_numa_node_read(dev_queue));
610616

0 commit comments

Comments
 (0)