Fix memory leak when blake is removed
Eric Miao [Tue, 26 Jan 2016 23:12:26 +0000 (15:12 -0800)]
Bug 200168010

Change-Id: I3310d0e3aca17a4aed9610e42522786c3d661fc9
Signed-off-by: Eric Miao <emiao@nvidia.com>
Signed-off-by: Li Li <lli5@nvidia.com>
Reviewed-on: http://git-master/r/1000107
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vinayak Pane <vpane@nvidia.com>

drivers/hid/hid-nvidia-blake.c

index a75fbb4..b1c6c6c 100644 (file)
@@ -415,7 +415,7 @@ static int nvidia_probe(struct hid_device *hdev, const struct hid_device_id *id)
        int ret;
        struct nvidia_tp_loc *loc;
 
-       loc = kmalloc(sizeof(*loc), GFP_KERNEL);
+       loc = devm_kzalloc(&hdev->dev, sizeof(*loc), GFP_KERNEL);
        if (!loc) {
                hid_err(hdev, "cannot alloc device touchpad state\n");
                return -ENOMEM;
@@ -457,7 +457,6 @@ static int nvidia_probe(struct hid_device *hdev, const struct hid_device_id *id)
        return 0;
 
 err_parse:
-       kfree(loc);
        return ret;
 }