On Fri, 28 Jun 2019 14:39:32 -0700, Shannon Nelson wrote:
> @@ -1260,10 +1266,24 @@ static struct lif *ionic_lif_alloc(struct ionic 
> *ionic, unsigned int index)
>       if (err)
>               goto err_out_free_lif_info;
>  
> +     /* allocate rss indirection table */
> +     tbl_sz = le16_to_cpu(lif->ionic->ident.lif.eth.rss_ind_tbl_sz);
> +     lif->rss_ind_tbl_sz = sizeof(*lif->rss_ind_tbl) * tbl_sz;
> +     lif->rss_ind_tbl = dma_alloc_coherent(dev, lif->rss_ind_tbl_sz,
> +                                           &lif->rss_ind_tbl_pa,
> +                                           GFP_KERNEL);
> +
> +     if (!lif->rss_ind_tbl) {
> +             dev_err(dev, "Failed to allocate rss indirection table, 
> aborting\n");
> +             goto err_out_free_qcqs;
> +     }
> +
>       list_add_tail(&lif->list, &ionic->lifs);
>  
>       return lif;
>  
> +err_out_free_qcqs:
> +     ionic_qcqs_free(lif);
>  err_out_free_lif_info:
>       dma_free_coherent(dev, lif->info_sz, lif->info, lif->info_pa);
>       lif->info = NULL;
> @@ -1302,6 +1322,14 @@ static void ionic_lif_free(struct lif *lif)
>  {
>       struct device *dev = lif->ionic->dev;
>  
> +     /* free rss indirection table */
> +     if (lif->rss_ind_tbl) {
> +             dma_free_coherent(dev, lif->rss_ind_tbl_sz, lif->rss_ind_tbl,
> +                               lif->rss_ind_tbl_pa);

dma_free_coherent() should be able to deal with NULLs just fine.
Besides you fail hard if the allocation failed, no?

> +             lif->rss_ind_tbl = NULL;
> +             lif->rss_ind_tbl_pa = 0;
> +     }

Reply via email to