All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] net: lan966x: Update FDMA to change MTU.
@ 2022-04-21 15:52 Dan Carpenter
  2022-05-11 13:59 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-04-21 15:52 UTC (permalink / raw)
  To: horatiu.vultur; +Cc: kernel-janitors

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] net: lan966x: Update FDMA to change MTU.
  2022-04-21 15:52 [bug report] net: lan966x: Update FDMA to change MTU Dan Carpenter
@ 2022-05-11 13:59 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2022-05-11 13:59 UTC (permalink / raw)
  To: horatiu.vultur; +Cc: kernel-janitors

Ping!

regards,
dan carpenter

On Thu, Apr 21, 2022 at 06:52:48PM +0300, Dan Carpenter wrote:
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-11 13:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-21 15:52 [bug report] net: lan966x: Update FDMA to change MTU Dan Carpenter
2022-05-11 13:59 ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.