From: Eason Lai <eason.lai@mediatek.com>
To: <nbd@nbd.name>, <lorenzo@kernel.org>
Cc: <linux-wireless@vger.kernel.org>,
<linux-mediatek@lists.infradead.org>, <kun.wu@mediatek.com>,
<deren.wu@mediatek.com>, <sean.wang@mediatek.com>,
<quan.zhou@mediatek.com>, <ryder.lee@mediatek.com>,
<leon.yen@mediatek.com>, <litien.chang@mediatek.com>,
<jb.tsai@mediatek.com>, <jeff.hsu@mediatek.com>,
<eason.lai@mediatek.com>, Jeff Hsu <Jeff.Hsu@mediatek.com>
Subject: [PATCH] wifi: mt76: Fix coverity issue for dma init
Date: Wed, 28 Oct 2026 09:57:07 +0800 [thread overview]
Message-ID: <20261028015707.2214888-1-eason.lai@mediatek.com> (raw)
From: Jeff Hsu <Jeff.Hsu@mediatek.com>
Check the snprintf return value writing napi_dev->name
free both netdevs and return -EINVAL when < 0
Signed-off-by: Jeff Hsu <Jeff.Hsu@mediatek.com>
---
drivers/net/wireless/mediatek/mt76/dma.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
index a67880a9281c..2c5d67a5bb81 100644
--- a/drivers/net/wireless/mediatek/mt76/dma.c
+++ b/drivers/net/wireless/mediatek/mt76/dma.c
@@ -1157,8 +1157,12 @@ mt76_dma_init(struct mt76_dev *dev,
priv = netdev_priv(dev->tx_napi_dev);
*priv = dev;
- snprintf(dev->napi_dev->name, sizeof(dev->napi_dev->name), "%s",
- wiphy_name(dev->hw->wiphy));
+ if (snprintf(dev->napi_dev->name, sizeof(dev->napi_dev->name), "%s",
+ wiphy_name(dev->hw->wiphy)) < 0) {
+ free_netdev(dev->tx_napi_dev);
+ free_netdev(dev->napi_dev);
+ return -EINVAL;
+ }
dev->napi_dev->threaded = 1;
init_completion(&dev->mmio.wed_reset);
init_completion(&dev->mmio.wed_reset_complete);
--
2.45.2
reply other threads:[~2026-10-28 1:57 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=20261028015707.2214888-1-eason.lai@mediatek.com \
--to=eason.lai@mediatek.com \
--cc=deren.wu@mediatek.com \
--cc=jb.tsai@mediatek.com \
--cc=jeff.hsu@mediatek.com \
--cc=kun.wu@mediatek.com \
--cc=leon.yen@mediatek.com \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=litien.chang@mediatek.com \
--cc=lorenzo@kernel.org \
--cc=nbd@nbd.name \
--cc=quan.zhou@mediatek.com \
--cc=ryder.lee@mediatek.com \
--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