Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 404EA403B1E; Wed, 30 Sep 2026 19:31:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790796702; cv=none; b=EdkEvtsWbff5VwS70JrnFU7wHC+duvRaGk4pvh5MzQMFFD2Hpey8/MEEZg2YZGKmWgjNg1I6zqTmRhokofPcDJsIzJejrw2xNBoCJVbCELfpIHaWR05vPhqa9fHFGSjG3yjHfuQNS+oOGM7sPNH3tAL7ZE2aP4ajEKEBiygW9rw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790796702; c=relaxed/simple; bh=6Q+d1W7eFx+ON2/bkLljX1Rx2whGtbep326fC16Sr1Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AF67WEwcGay8R/bOM1mOA6Uiw5ykmv67yRujzzrTciEZhpPHS7+SXqM4DuIxp/EEjAZrziaYXtY9dUw5N123kJ/9WxCcx3O7eWphSpNZK59NhvB4uT2sHnlRrB8YK0Hqmnsnifbw9UmPAFwAg9555jga/Cp8M5REhQMEg6yrCXA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=L0MALu3Y; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="L0MALu3Y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92DA21F000FF; Wed, 30 Sep 2026 19:31:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790796701; bh=5PYtauxB2WaAFtB/WLa49IpWfzdJbXBqaL5R1ku3D2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=L0MALu3YRNvyMRfpUwv/EiXJBv+NxTybL4wSaaIedWeCzjA4jZa2ItZMlmqi84+Hs rXaufVl8EIJWQ4+loXu7JRPULfUxJTDCoYgQlt1AMKlUWMGsHCB5d4LQj9W/2mChi8 1oUJnZpYF0yqzZ4dG+vM4qt/URlpIhjXxd/ecDUQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Breno Leitao , "David S. Miller" , Sasha Levin Subject: [PATCH 6.6 1007/1193] net: mediatek: mtk_eth_sock: allocate dummy net_device dynamically Date: Wed, 30 Sep 2026 17:28:11 +0200 Message-ID: <20260930152456.616699003@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152434.301151190@linuxfoundation.org> References: <20260930152434.301151190@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Breno Leitao [ Upstream commit b209bd6d0bffb8991aba568e2d9a892c86a1a43c ] Embedding net_device into structures prohibits the usage of flexible arrays in the net_device structure. For more details, see the discussion at [1]. Un-embed the net_device from the private struct by converting it into a pointer. Then use the leverage the new alloc_netdev_dummy() helper to allocate and initialize dummy devices. [1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/ Signed-off-by: Breno Leitao Signed-off-by: David S. Miller Stable-dep-of: 310d1ac61a4d ("net: ethernet: mtk_eth_soc: unregister net_devices in case of probe failure") Signed-off-by: Sasha Levin --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 17 +++++++++++++---- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 6de783fe116ce..8cc5f94b1e8aa 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1714,7 +1714,7 @@ static struct page_pool *mtk_create_page_pool(struct mtk_eth *eth, if (IS_ERR(pp)) return pp; - err = __xdp_rxq_info_reg(xdp_q, ð->dummy_dev, id, + err = __xdp_rxq_info_reg(xdp_q, eth->dummy_dev, id, eth->rx_napi.napi_id, PAGE_SIZE); if (err < 0) goto err_free_pp; @@ -4249,6 +4249,8 @@ static int mtk_free_dev(struct mtk_eth *eth) dst_release(ð->dsa_meta[i]->dst); } + free_netdev(eth->dummy_dev); + return 0; } @@ -5044,9 +5046,14 @@ static int mtk_probe(struct platform_device *pdev) /* we run 2 devices on the same DMA ring so we need a dummy device * for NAPI to work */ - init_dummy_netdev(ð->dummy_dev); - netif_napi_add(ð->dummy_dev, ð->tx_napi, mtk_napi_tx); - netif_napi_add(ð->dummy_dev, ð->rx_napi, mtk_napi_rx); + eth->dummy_dev = alloc_netdev_dummy(0); + if (!eth->dummy_dev) { + err = -ENOMEM; + dev_err(eth->dev, "failed to allocated dummy device\n"); + goto err_unreg_netdev; + } + netif_napi_add(eth->dummy_dev, ð->tx_napi, mtk_napi_tx); + netif_napi_add(eth->dummy_dev, ð->rx_napi, mtk_napi_rx); platform_set_drvdata(pdev, eth); schedule_delayed_work(ð->reset.monitor_work, @@ -5054,6 +5061,8 @@ static int mtk_probe(struct platform_device *pdev) return 0; +err_unreg_netdev: + mtk_unreg_dev(eth); err_deinit_ppe: mtk_ppe_deinit(eth); mtk_mdio_cleanup(eth); diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index d1c7b5f1ee4a9..20d0580ea9775 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -1250,7 +1250,7 @@ struct mtk_eth { spinlock_t page_lock; spinlock_t tx_irq_lock; spinlock_t rx_irq_lock; - struct net_device dummy_dev; + struct net_device *dummy_dev; struct net_device *netdev[MTK_MAX_DEVS]; struct mtk_mac *mac[MTK_MAX_DEVS]; int irq[3]; -- 2.53.0