[bug report] net: lan966x: Update FDMA to change MTU.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Horatiu Vultur,

The patch 2ea1cbac267e: "net: lan966x: Update FDMA to change MTU."
from Apr 8, 2022, leads to the following Smatch static checker
warning:

	drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c:736 lan966x_fdma_reload()
	warn: 'rx_dcbs' was already freed.

drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
    685 static int lan966x_fdma_reload(struct lan966x *lan966x, int new_mtu)
    686 {
    687         void *rx_dcbs, *tx_dcbs, *tx_dcbs_buf;
    688         dma_addr_t rx_dma, tx_dma;
    689         u32 size;
    690         int err;
    691 
    692         /* Store these for later to free them */
    693         rx_dma = lan966x->rx.dma;
    694         tx_dma = lan966x->tx.dma;
    695         rx_dcbs = lan966x->rx.dcbs;
    696         tx_dcbs = lan966x->tx.dcbs;
    697         tx_dcbs_buf = lan966x->tx.dcbs_buf;
    698 
    699         napi_synchronize(&lan966x->napi);
    700         napi_disable(&lan966x->napi);
    701         lan966x_fdma_stop_netdev(lan966x);
    702 
    703         lan966x_fdma_rx_disable(&lan966x->rx);
    704         lan966x_fdma_rx_free_pages(&lan966x->rx);
    705         lan966x->rx.page_order = round_up(new_mtu, PAGE_SIZE) / PAGE_SIZE - 1;
    706         err = lan966x_fdma_rx_alloc(&lan966x->rx);
    707         if (err)
    708                 goto restore;
    709         lan966x_fdma_rx_start(&lan966x->rx);
    710 
    711         size = sizeof(struct lan966x_rx_dcb) * FDMA_DCB_MAX;
    712         size = ALIGN(size, PAGE_SIZE);
    713         dma_free_coherent(lan966x->dev, size, rx_dcbs, rx_dma);
                                                      ^^^^^^^
Freed

    714 
    715         lan966x_fdma_tx_disable(&lan966x->tx);
    716         err = lan966x_fdma_tx_alloc(&lan966x->tx);
    717         if (err)
    718                 goto restore_tx;
                        ^^^^^^^^^^^^^^^

    719 
    720         size = sizeof(struct lan966x_tx_dcb) * FDMA_DCB_MAX;
    721         size = ALIGN(size, PAGE_SIZE);
    722         dma_free_coherent(lan966x->dev, size, tx_dcbs, tx_dma);
    723 
    724         kfree(tx_dcbs_buf);
    725 
    726         lan966x_fdma_wakeup_netdev(lan966x);
    727         napi_enable(&lan966x->napi);
    728 
    729         return err;
    730 restore:
    731         lan966x->rx.dma = rx_dma;
    732         lan966x->tx.dma = tx_dma;
    733         lan966x_fdma_rx_start(&lan966x->rx);
    734 
    735 restore_tx:
--> 736         lan966x->rx.dcbs = rx_dcbs;
                                   ^^^^^^^

    737         lan966x->tx.dcbs = tx_dcbs;
    738         lan966x->tx.dcbs_buf = tx_dcbs_buf;
    739 
    740         return err;
    741 }

regards,
dan carpenter



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux