> +static void netif_free_tx_queues(struct net_device *dev)
> +{
> +     if (is_vmalloc_addr(dev->_tx))
> +             vfree(dev->_tx);
> +     else
> +             kfree(dev->_tx);
> +}
> +
>  static int netif_alloc_netdev_queues(struct net_device *dev)
>  {
>       unsigned int count = dev->num_tx_queues;
> @@ -5261,9 +5270,11 @@ static int netif_alloc_netdev_queues(struct net_device 
> *dev)
>       BUG_ON(count < 1);
> 
>       tx = kcalloc(count, sizeof(struct netdev_queue), GFP_KERNEL);
> -     if (!tx)
> -             return -ENOMEM;
> -
> +     if (!tx) {
> +             tx = vzalloc(count * sizeof(struct netdev_queue));
> +             if (!tx)
> +                     return -ENOMEM;
> +     }
>       dev->_tx = tx;

Given the number of places I've seen this code added, why
not put it in a general helper?

I also thought that malloc() with GFP_KERNEL would sleep.
Under what conditions does it fail instead?

        David

Reply via email to