[IBAL] fix memory leak on power down/power up flow. [mlnx: 4289]
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 4 May 2009 12:42:20 +0000 (12:42 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 4 May 2009 12:42:20 +0000 (12:42 +0000)
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/trunk@2149 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

core/bus/kernel/bus_iou_mgr.c
core/bus/kernel/bus_port_mgr.c

index cdc0c62..0cce0cf 100644 (file)
@@ -357,7 +357,6 @@ destroying_iou_mgr(
                status = ib_dereg_pnp( bus_globals.h_pnp_iou, NULL );\r
                bus_globals.h_pnp_iou = NULL;\r
                CL_ASSERT( status == IB_SUCCESS );\r
-               BUS_TRACE(BUS_DBG_PNP, ("%s deregister IOU PNP\n", p_bfi->whoami) );\r
        }\r
        cl_obj_deref( p_bfi->p_iou_mgr_obj );\r
 \r
@@ -427,6 +426,11 @@ free_iou_mgr(
                                        p_bfi->whoami, p_ext->cl_ext.vfptr_pnp_po->identity,\r
                                        p_ext->cl_ext.p_self_do, p_ext ) );\r
 \r
+               BUS_TRACE( BUS_DBG_PNP,("%s p_ext->h_ca->obj.state %d ref_cnt %d\n",\r
+                                       p_bfi->whoami,\r
+                                       p_ext->h_ca->obj.state,\r
+                                       p_ext->h_ca->obj.ref_cnt));\r
+\r
                IoDeleteDevice( p_ext->cl_ext.p_self_do );\r
        }\r
 \r
@@ -864,8 +868,7 @@ iou_mgr_iou_remove(
                        p_ext->cl_ext.vfptr_pnp_po->identity, p_ext->cl_ext.p_self_do,\r
                        p_ext, p_ext->b_present, \r
                        p_ext->b_reported_missing, p_ext->b_hibernating ) );\r
-               deref_al_obj( &p_ext->h_ca->obj );\r
-               goto xit;\r
+               goto hca_deref;\r
        }\r
 \r
        p_ext->b_present = FALSE;\r
@@ -884,13 +887,12 @@ iou_mgr_iou_remove(
        IoInvalidateDeviceRelations(\r
                p_ext->h_ca->p_hca_dev, BusRelations );\r
 \r
+hca_deref:\r
        /* free PNP context */\r
        cl_free( p_ctx );\r
        p_pnp_rec->pnp_rec.context = NULL;\r
-       deref_al_obj( &p_ext->h_ca->obj );\r
-       p_ext->h_ca = NULL;     // for free_iou_mgr()\r
 \r
-xit:\r
+       deref_al_obj( &p_ext->h_ca->obj );\r
        cl_mutex_release( &gp_iou_mgr->pdo_mutex );\r
 \r
        BUS_EXIT( BUS_DBG_PNP );\r
index c0c3a68..5e410c9 100644 (file)
@@ -1268,11 +1268,11 @@ port_mgr_port_remove(
        IoInvalidateDeviceRelations(\r
                p_ext->h_ca->p_hca_dev, BusRelations );\r
 \r
+hca_deref:\r
        /* Free PNP context memory */\r
        cl_free( p_ctx );\r
        p_pnp_rec->pnp_rec.context = NULL;\r
 \r
-hca_deref:\r
        deref_al_obj( &p_ext->h_ca->obj );\r
        \r
        //      Setting h_ca to be NULL forces IPoIB to start only after re-acquiring new CA object\r