提交 057c2a2e 编写于 作者: G Guennadi Liakhovetski 提交者: Mauro Carvalho Chehab

[media] V4L: soc-camera: explicitly free allocated managed memory on error

devm_kzalloc() allocations are freed when the device is unbound. But if a
certain path fails and the allocated memory cannot be used anyway it is
better to free it explicitly immediately. This patch does exactly this if
asynchronous group probing in scan_async_group() fails after memory has
been allocated.
Signed-off-by: NGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: NMauro Carvalho Chehab <m.chehab@samsung.com>
上级 3926d91a
......@@ -1524,14 +1524,14 @@ static int scan_async_group(struct soc_camera_host *ici,
ret = soc_camera_dyn_pdev(&sdesc, sasc);
if (ret < 0)
return ret;
goto eallocpdev;
sasc->sensor = &sasd->asd;
icd = soc_camera_add_pdev(sasc);
if (!icd) {
platform_device_put(sasc->pdev);
return -ENOMEM;
ret = -ENOMEM;
goto eaddpdev;
}
sasc->notifier.subdevs = asd;
......@@ -1559,7 +1559,11 @@ static int scan_async_group(struct soc_camera_host *ici,
v4l2_clk_unregister(icd->clk);
eclkreg:
icd->clk = NULL;
platform_device_unregister(sasc->pdev);
platform_device_del(sasc->pdev);
eaddpdev:
platform_device_put(sasc->pdev);
eallocpdev:
devm_kfree(ici->v4l2_dev.dev, sasc);
dev_err(ici->v4l2_dev.dev, "group probe failed: %d\n", ret);
return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册