[mlx4] Fix error handling of mlx4_bus driver.
authortzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 11 Feb 2009 10:32:07 +0000 (10:32 +0000)
committertzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 11 Feb 2009 10:32:07 +0000 (10:32 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@1941 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mlx4/kernel/bus/core/device.c
hw/mlx4/kernel/bus/ib/main.c
hw/mlx4/kernel/hca/drv.c

index d20b110..8999713 100644 (file)
@@ -332,6 +332,11 @@ void ib_unregister_device(struct ib_device *device)
        struct ib_client_data *context, *tmp;
        unsigned long flags;
 
+       if(device->reg_state != IB_DEV_REGISTERED) {
+               ASSERT(device->reg_state == IB_DEV_REGISTERED);
+               return;
+       }
+
        mutex_lock(&device_mutex);
 
        list_for_each_entry_reverse(client, &client_list, list, struct ib_client)
@@ -340,8 +345,14 @@ void ib_unregister_device(struct ib_device *device)
 
        list_del(&device->core_list);
 
-       kfree(device->gid_tbl_len);
-       kfree(device->pkey_tbl_len);
+       if (device->gid_tbl_len) {
+               kfree(device->gid_tbl_len);
+               device->gid_tbl_len = NULL;
+       }
+       if(device->pkey_tbl_len) {
+               kfree(device->pkey_tbl_len);
+               device->pkey_tbl_len = NULL;
+       }
 
        mutex_unlock(&device_mutex);
 
index a6001ab..1781092 100644 (file)
@@ -621,8 +621,10 @@ static void mlx4_ib_remove(struct mlx4_dev *dev, void *ibdev_ptr)
        struct mlx4_ib_dev *ibdev = ibdev_ptr;
        int p;
 
-       if (mlx4_is_livefish(ibdev->dev))
+       if (mlx4_is_livefish(ibdev->dev)) {
+               ib_unregister_device(&ibdev->ib_dev);
                goto dealloc_dev;
+       }
        
        for (p = 1; p <= dev->caps.num_ports; ++p)
                mlx4_CLOSE_PORT(dev, p);
index 8c5aed4..2ffd485 100644 (file)
@@ -713,7 +713,7 @@ EvtDeviceReleaseHardware(
 \r
        HCA_ENTER( HCA_DBG_PNP );\r
 \r
-       HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_PNP, ("EvtReleaseHardware: FdoData=0x%p\n", p_fdo));\r
+       HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_PNP, ("EvtDeviceReleaseHardware: FdoData=0x%p\n", p_fdo));\r
 \r
        // release IBBUS resources\r
        __hca_release_resources(Device);\r