 RDMA/efa: Fix wrong resources deallocation order · gregkh/linux@e79db2f · 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 e79db2f 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 a1ceb30 commit e79db2f Copy full SHA for e79db2f 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 @@ -449,12 +449,12 @@ int efa_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata) 449 449 450 450 ibdev_dbg ( &amp; dev -&gt; ibdev , &quot;Destroy qp[%u]\n&quot; , ibqp -&gt; qp_num ); 451 451 452 - efa_qp_user_mmap_entries_remove ( qp ); 453 - 454 452 err = efa_destroy_qp_handle ( dev , qp -&gt; qp_handle ); 455 453 if ( err ) 456 454 return err ; 457 455 456 + efa_qp_user_mmap_entries_remove ( qp ); 457 + 458 458 if ( qp -&gt; rq_cpu_addr ) { 459 459 ibdev_dbg ( &amp; dev -&gt; ibdev , 460 460 &quot;qp-&gt;cpu_addr[0x%p] freed: size[%lu], dma[%pad]\n&quot; , @@ -1013,8 +1013,8 @@ int efa_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) 1013 1013 &quot;Destroy cq[%d] virt[0x%p] freed: size[%lu], dma[%pad]\n&quot; , 1014 1014 cq -&gt; cq_idx , cq -&gt; cpu_addr , cq -&gt; size , &amp; cq -&gt; dma_addr ); 1015 1015 1016 - efa_cq_user_mmap_entries_remove ( cq ); 1017 1016 efa_destroy_cq_idx ( dev , cq -&gt; cq_idx ); 1017 + efa_cq_user_mmap_entries_remove ( cq ); 1018 1018 if ( cq -&gt; eq ) { 1019 1019 xa_erase ( &amp; dev -&gt; cqs_xa , cq -&gt; cq_idx ); 1020 1020 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. 