> +static void netif_free_cleanup_work(struct net_device *dev)
> +{
> + if (!dev->cleanup_work)
> + return;
> +
> + cancel_work_sync(&dev->cleanup_work->work);
> + kfree(dev->cleanup_work);
> + dev->cleanup_work = NULL;
> +}
> +
> @@ -1682,6 +1882,16 @@ static int __dev_open(struct net_device *dev, struct
> netlink_ext_ack *extack)
> if (!ret && ops->ndo_open)
> ret = ops->ndo_open(dev);
>
> + if (!ret && dev->needs_cleanup_work) {
> + if (!dev->cleanup_work)
> + ret = netif_alloc_cleanup_work(dev);
> + else
> + cancel_work_sync(&dev->cleanup_work->work);
> + }
> +
> + if (!ret && ops->ndo_write_rx_mode)
> + ret = netif_alloc_rx_mode_ctx(dev);
> +
> netpoll_poll_enable(dev);
This is the response to the AI review. Honestly impressed by how good
the AI review is
My bad, It should be flush_work() not cancel_work_sync() in
__dev_open() and also in
netif_free_cleanup_work(). These are the only places where execution
needs to wait
for completion of the cleanup work
It's ok to just cancel rx_mode work so this issue is only with the cleanup work