The probe() function performs a kzalloc to dynamically allocate memory
at runtime. If the allocation succeeds, yet invoking the function
i2c_add_adapter fails, the dynamically allocated memory is never freed.
Change the allocation to use the managed allocation API instead and
remove the manual freeing of the memory in the remove() function.
Signed-off-by: Geordan Neukum <gneukum1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
dev_dbg(&pldev->dev, "pi2c_probe(pldev = %p '%s')\n", pldev, pldev->name);
- priv = kzalloc(sizeof(struct i2c_device), GFP_KERNEL);
+ priv = devm_kzalloc(&pldev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv) {
return -ENOMEM;
}
//pci_set_drvdata(dev, NULL);
//cdev_del(&lddev->cdev);
- if(lddev != 0) {
- kfree(lddev);
- pldev->dev.platform_data = 0;
- }
return 0;
}