All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: horatiu.vultur@microchip.com
Cc: kernel-janitors@vger.kernel.org
Subject: [bug report] net: lan966x: Update FDMA to change MTU.
Date: Thu, 21 Apr 2022 18:52:48 +0300	[thread overview]
Message-ID: <YmF90Dj/DKXoRMiq@kili> (raw)

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

             reply	other threads:[~2022-04-21 15:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21 15:52 Dan Carpenter [this message]
2022-05-11 13:59 ` [bug report] net: lan966x: Update FDMA to change MTU Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YmF90Dj/DKXoRMiq@kili \
    --to=dan.carpenter@oracle.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=kernel-janitors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.