public inbox for linux-mediatek@lists.infradead.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Sean Wang <sean.wang@mediatek.com>
Cc: linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org
Subject: [bug report] wifi: mt76: mt7921: handle MT7902 irq_map quirk with mutable copy
Date: Fri, 10 Apr 2026 13:13:35 +0300	[thread overview]
Message-ID: <adjNTwO_ziI9eLWU@stanley.mountain> (raw)

Hello Sean Wang,

Commit 222606f43b58 ("wifi: mt76: mt7921: handle MT7902 irq_map quirk
with mutable copy") from Feb 18, 2026 (linux-next), leads to the
following Smatch static checker warning:

	drivers/net/wireless/mediatek/mt76/mt7921/pci.c:363 mt7921_pci_probe()
	warn: missing unwind goto?

drivers/net/wireless/mediatek/mt76/mt7921/pci.c
    258 static int mt7921_pci_probe(struct pci_dev *pdev,
    259                             const struct pci_device_id *id)
    260 {
    261         static const struct mt76_driver_ops drv_ops = {
    262                 /* txwi_size = txd size + txp size */
    263                 .txwi_size = MT_TXD_SIZE + sizeof(struct mt76_connac_hw_txp),
    264                 .drv_flags = MT_DRV_TXWI_NO_FREE | MT_DRV_HW_MGMT_TXQ |
    265                              MT_DRV_AMSDU_OFFLOAD,
    266                 .survey_flags = SURVEY_INFO_TIME_TX |
    267                                 SURVEY_INFO_TIME_RX |
    268                                 SURVEY_INFO_TIME_BSS_RX,
    269                 .token_size = MT7921_TOKEN_SIZE,
    270                 .tx_prepare_skb = mt7921e_tx_prepare_skb,
    271                 .tx_complete_skb = mt76_connac_tx_complete_skb,
    272                 .rx_check = mt7921_rx_check,
    273                 .rx_skb = mt7921_queue_rx_skb,
    274                 .rx_poll_complete = mt792x_rx_poll_complete,
    275                 .sta_add = mt7921_mac_sta_add,
    276                 .sta_event = mt7921_mac_sta_event,
    277                 .sta_remove = mt7921_mac_sta_remove,
    278                 .update_survey = mt792x_update_channel,
    279                 .set_channel = mt7921_set_channel,
    280         };
    281         static const struct mt792x_hif_ops mt7921_pcie_ops = {
    282                 .init_reset = mt7921e_init_reset,
    283                 .reset = mt7921e_mac_reset,
    284                 .mcu_init = mt7921e_mcu_init,
    285                 .drv_own = mt792xe_mcu_drv_pmctrl,
    286                 .fw_own = mt792xe_mcu_fw_pmctrl,
    287         };
    288         static const struct mt792x_irq_map irq_map = {
    289                 .host_irq_enable = MT_WFDMA0_HOST_INT_ENA,
    290                 .tx = {
    291                         .all_complete_mask = MT_INT_TX_DONE_ALL,
    292                         .mcu_complete_mask = MT_INT_TX_DONE_MCU,
    293                 },
    294                 .rx = {
    295                         .data_complete_mask = MT_INT_RX_DONE_DATA,
    296                         .wm_complete_mask = MT_INT_RX_DONE_WM,
    297                         .wm2_complete_mask = MT_INT_RX_DONE_WM2,
    298                 },
    299         };
    300         struct ieee80211_ops *ops;
    301         struct mt76_bus_ops *bus_ops;
    302         struct mt792x_dev *dev;
    303         struct mt76_dev *mdev;
    304         void __iomem *regs;
    305         u16 cmd, chipid;
    306         u8 features;
    307         int ret;
    308 
    309         ret = pcim_enable_device(pdev);
    310         if (ret)
    311                 return ret;
    312 
    313         pci_read_config_word(pdev, PCI_COMMAND, &cmd);
    314         if (!(cmd & PCI_COMMAND_MEMORY)) {
    315                 cmd |= PCI_COMMAND_MEMORY;
    316                 pci_write_config_word(pdev, PCI_COMMAND, cmd);
    317         }
    318         pci_set_master(pdev);
    319 
    320         ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
    321         if (ret < 0)
    322                 return ret;
    323 
    324         ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
    325         if (ret)
    326                 goto err_free_pci_vec;
    327 
    328         if (mt7921_disable_aspm)
    329                 mt76_pci_disable_aspm(pdev);
    330 
    331         ops = mt792x_get_mac80211_ops(&pdev->dev, &mt7921_ops,
    332                                       (void *)id->driver_data, &features);
    333         if (!ops) {
    334                 ret = -ENOMEM;
    335                 goto err_free_pci_vec;
    336         }
    337 
    338         mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), ops, &drv_ops);
    339         if (!mdev) {
    340                 ret = -ENOMEM;
    341                 goto err_free_pci_vec;
    342         }
    343 
    344         pci_set_drvdata(pdev, mdev);
    345 
    346         regs =  pcim_iomap_region(pdev, 0, pci_name(pdev));
    347         if (IS_ERR(regs))
    348                 return PTR_ERR(regs);

Need to goto to err_free_pci_vec before returning

    349 
    350         dev = container_of(mdev, struct mt792x_dev, mt76);
    351         dev->fw_features = features;
    352         dev->hif_ops = &mt7921_pcie_ops;
    353         dev->irq_map = &irq_map;
    354         mt76_mmio_init(&dev->mt76, regs);
    355 
    356         if (id->device == 0x7902) {
    357                 struct mt792x_irq_map *map;
    358 
    359                 /* MT7902 needs a mutable copy because wm2_complete_mask differs */
    360                 map = devm_kmemdup(&pdev->dev, &irq_map,
    361                                    sizeof(irq_map), GFP_KERNEL);
    362                 if (!map)
--> 363                         return -ENOMEM;

Same.

    364 
    365                 map->rx.wm2_complete_mask = 0;
    366                 dev->irq_map = map;
    367         }
    368 
    369         tasklet_init(&mdev->irq_tasklet, mt792x_irq_tasklet, (unsigned long)dev);
    370 
    371         dev->phy.dev = dev;
    372         dev->phy.mt76 = &dev->mt76.phy;
    373         dev->mt76.phy.priv = &dev->phy;
    374         dev->bus_ops = dev->mt76.bus;
    375         bus_ops = devm_kmemdup(dev->mt76.dev, dev->bus_ops, sizeof(*bus_ops),
    376                                GFP_KERNEL);
    377         if (!bus_ops) {
    378                 ret = -ENOMEM;
    379                 goto err_free_dev;
    380         }
    381 
    382         bus_ops->rr = mt7921_rr;
    383         bus_ops->wr = mt7921_wr;
    384         bus_ops->rmw = mt7921_rmw;
    385         dev->mt76.bus = bus_ops;
    386 
    387         if (!mt7921_disable_aspm && mt76_pci_aspm_supported(pdev))
    388                 dev->aspm_supported = true;
    389 
    390         ret = mt792xe_mcu_fw_pmctrl(dev);
    391         if (ret)
    392                 goto err_free_dev;
    393 
    394         ret = __mt792xe_mcu_drv_pmctrl(dev);
    395         if (ret)
    396                 goto err_free_dev;
    397 
    398         chipid = mt7921_l1_rr(dev, MT_HW_CHIPID);
    399         if (chipid == 0x7961 && (mt7921_l1_rr(dev, MT_HW_BOUND) & BIT(7)))
    400                 chipid = 0x7920;
    401         mdev->rev = (chipid << 16) |
    402                     (mt7921_l1_rr(dev, MT_HW_REV) & 0xff);
    403         dev_info(mdev->dev, "ASIC revision: %04x\n", mdev->rev);
    404 
    405         ret = mt792x_wfsys_reset(dev);
    406         if (ret)
    407                 goto err_free_dev;
    408 
    409         mt76_wr(dev, irq_map.host_irq_enable, 0);
    410 
    411         mt76_wr(dev, MT_PCIE_MAC_INT_ENABLE, 0xff);
    412 
    413         ret = devm_request_irq(mdev->dev, pdev->irq, mt792x_irq_handler,
    414                                IRQF_SHARED, KBUILD_MODNAME, dev);
    415         if (ret)
    416                 goto err_free_dev;
    417 
    418         ret = mt7921_dma_init(dev);
    419         if (ret)
    420                 goto err_free_irq;
    421 
    422         ret = mt7921_register_device(dev);
    423         if (ret)
    424                 goto err_free_irq;
    425 
    426         if (of_property_read_bool(dev->mt76.dev->of_node, "wakeup-source"))
    427                 device_init_wakeup(dev->mt76.dev, true);
    428 
    429         return 0;
    430 
    431 err_free_irq:
    432         devm_free_irq(&pdev->dev, pdev->irq, dev);
    433 err_free_dev:
    434         mt76_free_device(&dev->mt76);
    435 err_free_pci_vec:
    436         pci_free_irq_vectors(pdev);
    437 
    438         return ret;
    439 }

This email is a free service from the Smatch-CI project [smatch.sf.net].

regards,
dan carpenter


                 reply	other threads:[~2026-04-10 10:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=adjNTwO_ziI9eLWU@stanley.mountain \
    --to=error27@gmail.com \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=sean.wang@mediatek.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox