mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 22:21:42 +00:00
media: ov5640: Fix a memory leak when ov5640_probe fails
sensor->ctrls.handler is initialized in ov5640_init_controls(),
so when the sensor is not connected and ov5640_sensor_resume()
fails, sensor->ctrls.handler should be released, otherwise a
memory leak will be detected:
unreferenced object 0xc674ca80 (size 64):
comm "swapper/0", pid 1, jiffies 4294938337 (age 204.880s)
hex dump (first 32 bytes):
80 55 75 c6 80 54 75 c6 00 55 75 c6 80 52 75 c6 .Uu..Tu..Uu..Ru.
00 53 75 c6 00 00 00 00 00 00 00 00 00 00 00 00 .Su..........
Fixes: 85644a9b37
("media: ov5640: Use runtime PM")
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
parent
a6403dddae
commit
20290feaae
@ -3928,7 +3928,7 @@ static int ov5640_probe(struct i2c_client *client)
|
||||
ret = ov5640_sensor_resume(dev);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to power on\n");
|
||||
goto entity_cleanup;
|
||||
goto free_ctrls;
|
||||
}
|
||||
|
||||
pm_runtime_set_active(dev);
|
||||
@ -3953,8 +3953,9 @@ static int ov5640_probe(struct i2c_client *client)
|
||||
err_pm_runtime:
|
||||
pm_runtime_put_noidle(dev);
|
||||
pm_runtime_disable(dev);
|
||||
v4l2_ctrl_handler_free(&sensor->ctrls.handler);
|
||||
ov5640_sensor_suspend(dev);
|
||||
free_ctrls:
|
||||
v4l2_ctrl_handler_free(&sensor->ctrls.handler);
|
||||
entity_cleanup:
|
||||
media_entity_cleanup(&sensor->sd.entity);
|
||||
mutex_destroy(&sensor->lock);
|
||||
|
Loading…
Reference in New Issue
Block a user