On 2026-11-28 12:36 +0000, netd…@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential > issue(s) to consider. > > Critical: 0 · High: 0 · Medium: 1 (1) · Low: 0 > > If you believe none of the issues are legitimate, please reply to each > issue of Medium severity or higher and explain why the AI is wrong. > If any of them are legitimate and you plan to respin, please let patchwork > know by including "pw-bot: cr" as a separate line at the end of your reply > (one such reply per series is enough). > > - [Medium] The commit message describes a different bug from the one the > new `dev->rx_buf_ring.desc = NULL` line fixes, and the only Fixes: tag… > > Pre-existing issues: > - [Medium] mtk_wed_rx_reset() frees the RX buffer-manager resources only > on full success. > > -- > > net: ethernet: mtk_wed: fix double free in mtk_wed_rx_reset > > mtk_wed_free_rx_buffer() already calls mtk_wed_hwrro_free_buffer(), so > this patch removes the second mtk_wed_hwrro_free_buffer() call in > mtk_wed_rx_reset(). It also sets dev->rx_buf_ring.desc, dev->hw_rro.desc > and dev->hw_rro.pages to NULL after they are freed, so the existing NULL > checks work. > > Link: https://sashiko.dev/#/map/216156 >
> > diff --git a/drivers/net/ethernet/mediatek/mtk_wed.c b/drivers/net/ethernet/mediatek/mtk_wed.c > > index 0bae252477987..0f215dd3d2d44 100644 > > --- a/drivers/net/ethernet/mediatek/mtk_wed.c > > +++ b/drivers/net/ethernet/mediatek/mtk_wed.c
> > [ ... ] >
> > @@ -896,6 +898,7 @@ mtk_wed_free_rx_buffer(struct mtk_wed_device *dev) > > dev->wlan.release_rx_buf(dev); > > dma_free_coherent(dev->hw->dev, dev->rx_buf_ring.size * sizeof(*desc), > > desc, dev->rx_buf_ring.desc_phys); > > + dev->rx_buf_ring.desc = NULL;
> > [Severity: Medium] > Does this line fix an older bug than the one the Fixes: tag names? > > The commit message describes the duplicated mtk_wed_hwrro_free_buffer() > call. Removing that call is enough to fix that bug. The only tag is: > > Fixes: 1543b8ff02f0 ("net: ethernet: mtk_wed: add wed 3.0 reset support") > > The stale rx_buf_ring.desc pointer goes back further, to b08134c6e109 > ("net: ethernet: mtk_wed: add mtk_wed_rx_reset routine"). That commit added > the mtk_wed_free_rx_buffer() call at the end of mtk_wed_rx_reset() and > moved mtk_wed_rx_buffer_alloc() into mtk_wed_start(). It also affects WED > v2 (MT7986/MT7915). > > Before this patch, rx_buf_ring.desc stays dangling after a reset until the > next successful mtk_wed_start(). There are two ways the restart can be > skipped. > > The first is mt7915_dma_start() with wed_reset=true returning early: > > drivers/net/wireless/mediatek/mt76/mt7915/dma.c:mt7915_dma_start() { > ... > ret = mt7915_mcu_wed_enable_rx_stats(dev); > if (ret) > return ret; > > mtk_wed_device_start(&dev->mt76.mmio.wed, wed_irq_mask); > ... > } > > The second is mtk_wed_start() bailing out when dma_alloc_coherent() fails > in mtk_wed_rx_buffer_alloc(). > > In either case, a later detach runs the free path again on the stale > pointer: > > __mtk_wed_detach() > mtk_wed_free_rx_rings() > mtk_wed_free_rx_buffer() > dev->wlan.release_rx_buf(dev); > dma_free_coherent(..., desc, ...); > > With only 1543b8ff02f0 tagged, would stable trees that have b08134c6e109 > but not the hwrro code (such as 6.6.y) miss this part of the fix? > > Would it make sense to add a Fixes: tag for b08134c6e109 and describe the > reset->detach double free in the commit message? > > Also, the commit message says dev->hw_rro.page, but the field is > dev->hw_rro.pages.
ACK, I will update the commit message and fix tag. Best regard, Zhi-Jun pw-bot: cr
>
> > > > mtk_wed_hwrro_free_buffer(dev); > > } > > @@ -1722,7 +1725,6 @@ mtk_wed_rx_reset(struct mtk_wed_device *dev) > > false); > > } > > mtk_wed_free_rx_buffer(dev); > > - mtk_wed_hwrro_free_buffer(dev); > > > > return 0; > > }
> > [Severity: Medium] > This is a pre-existing issue and was not introduced by this patch. > mtk_wed_rx_reset() only reaches mtk_wed_free_rx_buffer() if every step > succeeds. Both mtk_wed_mcu_send_msg() state change calls return early on > error: > > ret = mtk_wed_mcu_send_msg(wo, MTK_WED_MODULE_ID_WO, > MTK_WED_WO_CMD_CHANGE_STATE, &val, > sizeof(val), true); > if (ret) > return ret; > > mtk_wed_reset_dma() then ignores the return value: > > if (mtk_wed_get_rx_capa(dev)) > mtk_wed_rx_reset(dev); > > After that, the WLAN reset flow calls mtk_wed_device_start() again. On > mt7915 this goes through > mt7915_dma_reset()->mt7915_dma_enable()->mt7915_dma_start(). > > mtk_wed_start() always calls mtk_wed_rx_buffer_alloc(). That function > overwrites the live pointers without releasing them first: > > dev->rx_buf_ring.desc = desc; > dev->rx_buf_ring.desc_phys = desc_phys; > dev->wlan.init_rx_buf(dev, dev->wlan.rx_npkt); > > mtk_wed_hwrro_buffer_alloc() overwrites dev->hw_rro.pages and > dev->hw_rro.desc in the same way. > > If a firmware message fails during SER recovery, can this leak the old > rx_buf_ring coherent ring? The same question applies to the hw_rro mapped > pages, page_list and coherent ring, and to the RX buffers taken by the > first init_rx_buf() call. > > -- > Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40gmail.com > >