From 9604f42d0910765c8a3df55a3a3694fd3d121ada Mon Sep 17 00:00:00 2001 From: leonidk Date: Mon, 4 May 2009 12:42:20 +0000 Subject: [PATCH] [IBAL] fix memory leak on power down/power up flow. [mlnx: 4289] port_mgr_port_add() allocates a port_pnp_ctx_t context, which is saved by IBAL to be used later in port_mgr_port_remove(). But in hibernation flow port_mgr_port_remove() doesn't release this context which causes IBBUS memory leak. It was trapped by Verifier during WHQL Common Scenario Stress test. git-svn-id: svn://openib.tc.cornell.edu/gen1@2149 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- trunk/core/bus/kernel/bus_iou_mgr.c | 14 ++++++++------ trunk/core/bus/kernel/bus_port_mgr.c | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/trunk/core/bus/kernel/bus_iou_mgr.c b/trunk/core/bus/kernel/bus_iou_mgr.c index cdc0c62d..0cce0cfc 100644 --- a/trunk/core/bus/kernel/bus_iou_mgr.c +++ b/trunk/core/bus/kernel/bus_iou_mgr.c @@ -357,7 +357,6 @@ destroying_iou_mgr( status = ib_dereg_pnp( bus_globals.h_pnp_iou, NULL ); bus_globals.h_pnp_iou = NULL; CL_ASSERT( status == IB_SUCCESS ); - BUS_TRACE(BUS_DBG_PNP, ("%s deregister IOU PNP\n", p_bfi->whoami) ); } cl_obj_deref( p_bfi->p_iou_mgr_obj ); @@ -427,6 +426,11 @@ free_iou_mgr( p_bfi->whoami, p_ext->cl_ext.vfptr_pnp_po->identity, p_ext->cl_ext.p_self_do, p_ext ) ); + BUS_TRACE( BUS_DBG_PNP,("%s p_ext->h_ca->obj.state %d ref_cnt %d\n", + p_bfi->whoami, + p_ext->h_ca->obj.state, + p_ext->h_ca->obj.ref_cnt)); + IoDeleteDevice( p_ext->cl_ext.p_self_do ); } @@ -864,8 +868,7 @@ iou_mgr_iou_remove( p_ext->cl_ext.vfptr_pnp_po->identity, p_ext->cl_ext.p_self_do, p_ext, p_ext->b_present, p_ext->b_reported_missing, p_ext->b_hibernating ) ); - deref_al_obj( &p_ext->h_ca->obj ); - goto xit; + goto hca_deref; } p_ext->b_present = FALSE; @@ -884,13 +887,12 @@ iou_mgr_iou_remove( IoInvalidateDeviceRelations( p_ext->h_ca->p_hca_dev, BusRelations ); +hca_deref: /* free PNP context */ cl_free( p_ctx ); p_pnp_rec->pnp_rec.context = NULL; - deref_al_obj( &p_ext->h_ca->obj ); - p_ext->h_ca = NULL; // for free_iou_mgr() -xit: + deref_al_obj( &p_ext->h_ca->obj ); cl_mutex_release( &gp_iou_mgr->pdo_mutex ); BUS_EXIT( BUS_DBG_PNP ); diff --git a/trunk/core/bus/kernel/bus_port_mgr.c b/trunk/core/bus/kernel/bus_port_mgr.c index c0c3a68c..5e410c94 100644 --- a/trunk/core/bus/kernel/bus_port_mgr.c +++ b/trunk/core/bus/kernel/bus_port_mgr.c @@ -1268,11 +1268,11 @@ port_mgr_port_remove( IoInvalidateDeviceRelations( p_ext->h_ca->p_hca_dev, BusRelations ); +hca_deref: /* Free PNP context memory */ cl_free( p_ctx ); p_pnp_rec->pnp_rec.context = NULL; -hca_deref: deref_al_obj( &p_ext->h_ca->obj ); // Setting h_ca to be NULL forces IPoIB to start only after re-acquiring new CA object -- 2.46.0