net-sysfs: update the queue counts in the unregistration path
authorAntoine Tenart <atenart@kernel.org>
Tue, 7 Dec 2021 14:57:24 +0000 (15:57 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 9 Dec 2021 02:36:32 +0000 (18:36 -0800)
When updating Rx and Tx queue kobjects, the queue count should always be
updated to match the queue kobjects count. This was not done in the net
device unregistration path, fix it. Tracking all queue count updates
will allow in a following up patch to detect illegal updates.

Signed-off-by: Antoine Tenart <atenart@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/net-sysfs.c

index 3b2cdbbdc858e06fb0a482a9b7fc778e501ba1e0..33f408c242050edc3a4a33c509fc182b8ac20b37 100644 (file)
@@ -1808,6 +1808,9 @@ static void remove_queue_kobjects(struct net_device *dev)
 
        net_rx_queue_update_kobjects(dev, real_rx, 0);
        netdev_queue_update_kobjects(dev, real_tx, 0);
+
+       dev->real_num_rx_queues = 0;
+       dev->real_num_tx_queues = 0;
 #ifdef CONFIG_SYSFS
        kset_unregister(dev->queues_kset);
 #endif