 bnxt_en: Fix memory corruption when FW resources change during ifdown · gregkh/linux@9ab6a99 · GitHub Skip to content Navigation Menu Toggle navigation Sign in Appearance settings Platform AI CODE CREATION GitHub Copilot Write better code with AI GitHub Spark Build and deploy intelligent apps GitHub Models Manage and compare prompts MCP Registry New Integrate external tools DEVELOPER WORKFLOWS Actions Automate any workflow Codespaces Instant dev environments Issues Plan and track work Code Review Manage code changes APPLICATION SECURITY GitHub Advanced Security Find and fix vulnerabilities Code security Secure your code as you build Secret protection  EXPLORE Why GitHub Documentation Blog Changelog Marketplace View all features Solutions BY COMPANY SIZE Enterprises Small and medium teams Startups Nonprofits BY USE CASE App Modernization DevSecOps DevOps CI/CD View all use cases BY INDUSTRY Healthcare Financial services Manufacturing Government View all industries View all solutions Resources EXPLORE BY TOPIC AI Software Development DevOps Security View all topics EXPLORE BY TYPE Customer stories Events &amp; webinars Ebooks &amp; reports Business insights GitHub Skills SUPPORT &amp; SERVICES Documentation Customer support Community forum Trust center Partners View all resources Open Source COMMUNITY GitHub Sponsors Fund open source developers PROGRAMS Security Lab Maintainer Community Accelerator GitHub Stars Archive Program REPOSITORIES Topics Trending Collections Enterprise ENTERPRISE SOLUTIONS Enterprise platform AI-powered developer platform AVAILABLE ADD-ONS GitHub Advanced Security Enterprise-grade security features Copilot for Business Enterprise-grade AI features Premium Support Enterprise-grade 24/7 support Pricing Search or jump to... Search code, repositories, users, issues, pull requests... --> Search Clear Search syntax tips Provide feedback --> We read every piece of feedback, and take your input very seriously.  Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly --> Name Query To see all available qualifiers, see our documentation . Cancel Create saved search Sign in Sign up Appearance settings Resetting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} gregkh / linux Public Notifications You must be signed in to change notification settings Fork 686 Star 644 Code Actions Security and quality 0 Insights Additional navigation options Code Actions Security and quality Insights Commit 9ab6a99 Browse files Browse files sreekanthbrcm authored and gregkh committed bnxt_en: Fix memory corruption when FW resources change during ifdown [ Upstream commit 2747328 ] bnxt_set_dflt_rings() assumes that it is always called before any TC has been created. So it doesn't take bp-&gt;num_tc into account and assumes that it is always 0 or 1. In the FW resource or capability change scenario, the FW will return flags in bnxt_hwrm_if_change() that will cause the driver to reinitialize and call bnxt_cancel_reservations(). This will lead to bnxt_init_dflt_ring_mode() calling bnxt_set_dflt_rings() and bp-&gt;num_tc may be greater than 1. This will cause bp-&gt;tx_ring[] to be sized too small and cause memory corruption in bnxt_alloc_cp_rings(). Fix it by properly scaling the TX rings by bp-&gt;num_tc in the code paths mentioned above. Add 2 helper functions to determine bp-&gt;tx_nr_rings and bp-&gt;tx_nr_rings_per_tc. Fixes: ec5d31e ("bnxt_en: Handle firmware reset status during IF_UP.") Reviewed-by: Kalesh AP &lt;kalesh-anakkur.purayil@broadcom.com&gt; Reviewed-by: Andy Gospodarek &lt;andrew.gospodarek@broadcom.com&gt; Signed-off-by: Sreekanth Reddy &lt;sreekanth.reddy@broadcom.com&gt; Signed-off-by: Michael Chan &lt;michael.chan@broadcom.com&gt; Link: https://patch.msgid.link/20250825175927.459987-2-michael.chan@broadcom.com Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt; Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt; 1 parent 1228285 commit 9ab6a99 Copy full SHA for 9ab6a99 1 file changed + 16 - 5 Lines changed: 16 additions &amp; 5 deletions File tree Expand file tree Collapse file tree Open diff view settings Filter options drivers/net/ethernet/broadcom/bnxt bnxt.c Expand file tree Collapse file tree Open diff view settings Collapse file ‎ drivers/net/ethernet/broadcom/bnxt/bnxt.c ‎ Copy file name to clipboard Expand all lines: drivers/net/ethernet/broadcom/bnxt/bnxt.c + 16 - 5 Lines changed: 16 additions &amp; 5 deletions Original file line number Diff line number Diff line change @@ -12844,6 +12844,17 @@ static int bnxt_set_xps_mapping(struct bnxt *bp) 12844 12844 return rc ; 12845 12845 } 12846 12846 12847 + static int bnxt_tx_nr_rings ( struct bnxt * bp ) 12848 + { 12849 + return bp -&gt; num_tc ? bp -&gt; tx_nr_rings_per_tc * bp -&gt; num_tc : 12850 + bp -&gt; tx_nr_rings_per_tc ; 12851 + } 12852 + 12853 + static int bnxt_tx_nr_rings_per_tc ( struct bnxt * bp ) 12854 + { 12855 + return bp -&gt; num_tc ? bp -&gt; tx_nr_rings / bp -&gt; num_tc : bp -&gt; tx_nr_rings ; 12856 + } 12857 + 12847 12858 static int __bnxt_open_nic ( struct bnxt * bp , bool irq_re_init , bool link_re_init ) 12848 12859 { 12849 12860 int rc = 0 ; @@ -16338,7 +16349,7 @@ static void bnxt_trim_dflt_sh_rings(struct bnxt *bp) 16338 16349 bp -&gt; cp_nr_rings = min_t ( int , bp -&gt; tx_nr_rings_per_tc , bp -&gt; rx_nr_rings ); 16339 16350 bp -&gt; rx_nr_rings = bp -&gt; cp_nr_rings ; 16340 16351 bp -&gt; tx_nr_rings_per_tc = bp -&gt; cp_nr_rings ; 16341 - bp -&gt; tx_nr_rings = bp -&gt; tx_nr_rings_per_tc ; 16352 + bp -&gt; tx_nr_rings = bnxt_tx_nr_rings ( bp ) ; 16342 16353 } 16343 16354 16344 16355 static int bnxt_set_dflt_rings ( struct bnxt * bp , bool sh ) @@ -16370,7 +16381,7 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh) 16370 16381 bnxt_trim_dflt_sh_rings ( bp ); 16371 16382 else 16372 16383 bp -&gt; cp_nr_rings = bp -&gt; tx_nr_rings_per_tc + bp -&gt; rx_nr_rings ; 16373 - bp -&gt; tx_nr_rings = bp -&gt; tx_nr_rings_per_tc ; 16384 + bp -&gt; tx_nr_rings = bnxt_tx_nr_rings ( bp ) ; 16374 16385 16375 16386 avail_msix = bnxt_get_max_func_irqs ( bp ) - bp -&gt; cp_nr_rings ; 16376 16387 if ( avail_msix &gt;= BNXT_MIN_ROCE_CP_RINGS ) { @@ -16383,7 +16394,7 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh) 16383 16394 rc = __bnxt_reserve_rings ( bp ); 16384 16395 if ( rc &amp;&amp; rc != - ENODEV ) 16385 16396 netdev_warn ( bp -&gt; dev , &quot;Unable to reserve tx rings\n&quot; ); 16386 - bp -&gt; tx_nr_rings_per_tc = bp -&gt; tx_nr_rings ; 16397 + bp -&gt; tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc ( bp ) ; 16387 16398 if ( sh ) 16388 16399 bnxt_trim_dflt_sh_rings ( bp ); 16389 16400 @@ -16392,7 +16403,7 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh) 16392 16403 rc = __bnxt_reserve_rings ( bp ); 16393 16404 if ( rc &amp;&amp; rc != - ENODEV ) 16394 16405 netdev_warn ( bp -&gt; dev , &quot;2nd rings reservation failed.\n&quot; ); 16395 - bp -&gt; tx_nr_rings_per_tc = bp -&gt; tx_nr_rings ; 16406 + bp -&gt; tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc ( bp ) ; 16396 16407 } 16397 16408 if ( BNXT_CHIP_TYPE_NITRO_A0 ( bp )) { 16398 16409 bp -&gt; rx_nr_rings ++ ; @@ -16426,7 +16437,7 @@ static int bnxt_init_dflt_ring_mode(struct bnxt *bp) 16426 16437 if ( rc ) 16427 16438 goto init_dflt_ring_err ; 16428 16439 16429 - bp -&gt; tx_nr_rings_per_tc = bp -&gt; tx_nr_rings ; 16440 + bp -&gt; tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc ( bp ) ; 16430 16441 16431 16442 bnxt_set_dflt_rfs ( bp ); 16432 16443 0 commit comments Comments 0 ( 0 ) Footer &copy; 2026 GitHub,&nbsp;Inc. Footer navigation Terms Privacy Security Status Community Docs Contact Manage cookies Do not share my personal information You can’t perform that action at this time. 