 RDMA/efa: Fix wrong resources deallocation order · gregkh/linux@cf38960 · 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 cf38960 Browse files Browse files YonatanNachum authored and gregkh committed RDMA/efa: Fix wrong resources deallocation order [ Upstream commit dc202c5 ] When trying to destroy QP or CQ, we first decrease the refcount and potentially free memory regions allocated for the object and then request the device to destroy the object. If the device fails, the object isn't fully destroyed so the user/IB core can try to destroy the object again which will lead to underflow when trying to decrease an already zeroed refcount. Deallocate resources in reverse order of allocating them to safely free them. Fixes: ff6629f ("RDMA/efa: Do not delay freeing of DMA pages") Reviewed-by: Michael Margolin &lt;mrgolin@amazon.com&gt; Reviewed-by: Yossi Leybovich &lt;sleybo@amazon.com&gt; Signed-off-by: Yonatan Nachum &lt;ynachum@amazon.com&gt; Link: https://lore.kernel.org/r/20230822082725.31719-1-ynachum@amazon.com Signed-off-by: Leon Romanovsky &lt;leon@kernel.org&gt; Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt; 1 parent 9d9a405 commit cf38960 Copy full SHA for cf38960 1 file changed + 3 - 3 Lines changed: 3 additions &amp; 3 deletions File tree Expand file tree Collapse file tree Open diff view settings Filter options drivers/infiniband/hw/efa efa_verbs.c Expand file tree Collapse file tree Open diff view settings Collapse file ‎ drivers/infiniband/hw/efa/efa_verbs.c ‎ Copy file name to clipboard Expand all lines: drivers/infiniband/hw/efa/efa_verbs.c + 3 - 3 Lines changed: 3 additions &amp; 3 deletions Original file line number Diff line number Diff line change @@ -443,12 +443,12 @@ int efa_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata) 443 443 444 444 ibdev_dbg ( &amp; dev -&gt; ibdev , &quot;Destroy qp[%u]\n&quot; , ibqp -&gt; qp_num ); 445 445 446 - efa_qp_user_mmap_entries_remove ( qp ); 447 - 448 446 err = efa_destroy_qp_handle ( dev , qp -&gt; qp_handle ); 449 447 if ( err ) 450 448 return err ; 451 449 450 + efa_qp_user_mmap_entries_remove ( qp ); 451 + 452 452 if ( qp -&gt; rq_cpu_addr ) { 453 453 ibdev_dbg ( &amp; dev -&gt; ibdev , 454 454 &quot;qp-&gt;cpu_addr[0x%p] freed: size[%lu], dma[%pad]\n&quot; , @@ -1007,8 +1007,8 @@ int efa_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) 1007 1007 &quot;Destroy cq[%d] virt[0x%p] freed: size[%lu], dma[%pad]\n&quot; , 1008 1008 cq -&gt; cq_idx , cq -&gt; cpu_addr , cq -&gt; size , &amp; cq -&gt; dma_addr ); 1009 1009 1010 - efa_cq_user_mmap_entries_remove ( cq ); 1011 1010 efa_destroy_cq_idx ( dev , cq -&gt; cq_idx ); 1011 + efa_cq_user_mmap_entries_remove ( cq ); 1012 1012 if ( cq -&gt; eq ) { 1013 1013 xa_erase ( &amp; dev -&gt; cqs_xa , cq -&gt; cq_idx ); 1014 1014 synchronize_irq ( cq -&gt; eq -&gt; irq . irqn ); 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. 