 bnxt_en: Fix memory corruption when FW resources change during ifdown · gregkh/linux@2747328 · 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 2747328 Browse files Browse files sreekanthbrcm authored and kuba-moo committed bnxt_en: Fix memory corruption when FW resources change during ifdown 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; 1 parent d9b0ca1 commit 2747328 Copy full SHA for 2747328 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 @@ -12851,6 +12851,17 @@ static int bnxt_set_xps_mapping(struct bnxt *bp) 12851 12851 return rc ; 12852 12852 } 12853 12853 12854 + static int bnxt_tx_nr_rings ( struct bnxt * bp ) 12855 + { 12856 + return bp -&gt; num_tc ? bp -&gt; tx_nr_rings_per_tc * bp -&gt; num_tc : 12857 + bp -&gt; tx_nr_rings_per_tc ; 12858 + } 12859 + 12860 + static int bnxt_tx_nr_rings_per_tc ( struct bnxt * bp ) 12861 + { 12862 + return bp -&gt; num_tc ? bp -&gt; tx_nr_rings / bp -&gt; num_tc : bp -&gt; tx_nr_rings ; 12863 + } 12864 + 12854 12865 static int __bnxt_open_nic ( struct bnxt * bp , bool irq_re_init , bool link_re_init ) 12855 12866 { 12856 12867 int rc = 0 ; @@ -16325,7 +16336,7 @@ static void bnxt_trim_dflt_sh_rings(struct bnxt *bp) 16325 16336 bp -&gt; cp_nr_rings = min_t ( int , bp -&gt; tx_nr_rings_per_tc , bp -&gt; rx_nr_rings ); 16326 16337 bp -&gt; rx_nr_rings = bp -&gt; cp_nr_rings ; 16327 16338 bp -&gt; tx_nr_rings_per_tc = bp -&gt; cp_nr_rings ; 16328 - bp -&gt; tx_nr_rings = bp -&gt; tx_nr_rings_per_tc ; 16339 + bp -&gt; tx_nr_rings = bnxt_tx_nr_rings ( bp ) ; 16329 16340 } 16330 16341 16331 16342 static int bnxt_set_dflt_rings ( struct bnxt * bp , bool sh ) @@ -16357,7 +16368,7 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh) 16357 16368 bnxt_trim_dflt_sh_rings ( bp ); 16358 16369 else 16359 16370 bp -&gt; cp_nr_rings = bp -&gt; tx_nr_rings_per_tc + bp -&gt; rx_nr_rings ; 16360 - bp -&gt; tx_nr_rings = bp -&gt; tx_nr_rings_per_tc ; 16371 + bp -&gt; tx_nr_rings = bnxt_tx_nr_rings ( bp ) ; 16361 16372 16362 16373 avail_msix = bnxt_get_max_func_irqs ( bp ) - bp -&gt; cp_nr_rings ; 16363 16374 if ( avail_msix &gt;= BNXT_MIN_ROCE_CP_RINGS ) { @@ -16370,7 +16381,7 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh) 16370 16381 rc = __bnxt_reserve_rings ( bp ); 16371 16382 if ( rc &amp;&amp; rc != - ENODEV ) 16372 16383 netdev_warn ( bp -&gt; dev , &quot;Unable to reserve tx rings\n&quot; ); 16373 - bp -&gt; tx_nr_rings_per_tc = bp -&gt; tx_nr_rings ; 16384 + bp -&gt; tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc ( bp ) ; 16374 16385 if ( sh ) 16375 16386 bnxt_trim_dflt_sh_rings ( bp ); 16376 16387 @@ -16379,7 +16390,7 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh) 16379 16390 rc = __bnxt_reserve_rings ( bp ); 16380 16391 if ( rc &amp;&amp; rc != - ENODEV ) 16381 16392 netdev_warn ( bp -&gt; dev , &quot;2nd rings reservation failed.\n&quot; ); 16382 - bp -&gt; tx_nr_rings_per_tc = bp -&gt; tx_nr_rings ; 16393 + bp -&gt; tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc ( bp ) ; 16383 16394 } 16384 16395 if ( BNXT_CHIP_TYPE_NITRO_A0 ( bp )) { 16385 16396 bp -&gt; rx_nr_rings ++ ; @@ -16413,7 +16424,7 @@ static int bnxt_init_dflt_ring_mode(struct bnxt *bp) 16413 16424 if ( rc ) 16414 16425 goto init_dflt_ring_err ; 16415 16426 16416 - bp -&gt; tx_nr_rings_per_tc = bp -&gt; tx_nr_rings ; 16427 + bp -&gt; tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc ( bp ) ; 16417 16428 16418 16429 bnxt_set_dflt_rfs ( bp ); 16419 16430 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. 