The devm_* functions eliminate the need for manual resource releasing
and simplify error handling. Resources allocated by devm_* are freed
automatically on driver detach.
Thus adding kfree calls here will introduce double free bug.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Cc: Geon Si Jeong <gshark.jeong@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
return -ENODATA;
}
- chip =
- devm_kzalloc(&client->dev, sizeof(struct lm3556_chip_data),
- GFP_KERNEL);
+ chip = devm_kzalloc(&client->dev, sizeof(struct lm3556_chip_data),
+ GFP_KERNEL);
if (!chip)
return -ENOMEM;
err_create_flash_file:
err_chip_init:
i2c_set_clientdata(client, NULL);
- kfree(chip);
return err;
}
led_classdev_unregister(&chip->cdev_flash);
lm3556_write_reg(client, REG_ENABLE, 0);
- kfree(chip);
return 0;
}