IB/cm: Correctly free cm_device structure
authorHefty, Sean <sean.hefty@intel.com>
Tue, 30 Sep 2008 17:36:54 +0000 (10:36 -0700)
committerRoland Dreier <rolandd@cisco.com>
Tue, 30 Sep 2008 17:36:54 +0000 (10:36 -0700)
commit 110cf374 ("infiniband: make cm_device use a struct device and
not a kobject.") introduced a memory leak, since it deleted
cm_release_dev_obj(), which was where cm_dev was freed.  Fix this by
freeing the leaked structure after calling device_unregister().

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/core/cm.c

index 922d35f4fc08aa07d69355a812577f9534e82567..3cab0cedfca21f54d83027a78f1f6c6a3c1a1b8e 100644 (file)
@@ -3748,6 +3748,7 @@ error1:
                cm_remove_port_fs(port);
        }
        device_unregister(cm_dev->device);
+       kfree(cm_dev);
 }
 
 static void cm_remove_one(struct ib_device *ib_device)
@@ -3776,6 +3777,7 @@ static void cm_remove_one(struct ib_device *ib_device)
                cm_remove_port_fs(port);
        }
        device_unregister(cm_dev->device);
+       kfree(cm_dev);
 }
 
 static int __init ib_cm_init(void)