diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2014-05-03 12:05:08 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-06-17 11:04:52 -0400 |
commit | 057c2a2ef576a21968e838194b8b9d3b6b106769 (patch) | |
tree | 5302cf37ea299f5ae58c853c9b1383084df2b255 | |
parent | 3926d91a6b93e42519a48325bf360a5b65460c14 (diff) |
[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: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r-- | drivers/media/platform/soc_camera/soc_camera.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index 7fec8cdaf095..dc626b9a177d 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c | |||
@@ -1524,14 +1524,14 @@ static int scan_async_group(struct soc_camera_host *ici, | |||
1524 | 1524 | ||
1525 | ret = soc_camera_dyn_pdev(&sdesc, sasc); | 1525 | ret = soc_camera_dyn_pdev(&sdesc, sasc); |
1526 | if (ret < 0) | 1526 | if (ret < 0) |
1527 | return ret; | 1527 | goto eallocpdev; |
1528 | 1528 | ||
1529 | sasc->sensor = &sasd->asd; | 1529 | sasc->sensor = &sasd->asd; |
1530 | 1530 | ||
1531 | icd = soc_camera_add_pdev(sasc); | 1531 | icd = soc_camera_add_pdev(sasc); |
1532 | if (!icd) { | 1532 | if (!icd) { |
1533 | platform_device_put(sasc->pdev); | 1533 | ret = -ENOMEM; |
1534 | return -ENOMEM; | 1534 | goto eaddpdev; |
1535 | } | 1535 | } |
1536 | 1536 | ||
1537 | sasc->notifier.subdevs = asd; | 1537 | sasc->notifier.subdevs = asd; |
@@ -1559,7 +1559,11 @@ static int scan_async_group(struct soc_camera_host *ici, | |||
1559 | v4l2_clk_unregister(icd->clk); | 1559 | v4l2_clk_unregister(icd->clk); |
1560 | eclkreg: | 1560 | eclkreg: |
1561 | icd->clk = NULL; | 1561 | icd->clk = NULL; |
1562 | platform_device_unregister(sasc->pdev); | 1562 | platform_device_del(sasc->pdev); |
1563 | eaddpdev: | ||
1564 | platform_device_put(sasc->pdev); | ||
1565 | eallocpdev: | ||
1566 | devm_kfree(ici->v4l2_dev.dev, sasc); | ||
1563 | dev_err(ici->v4l2_dev.dev, "group probe failed: %d\n", ret); | 1567 | dev_err(ici->v4l2_dev.dev, "group probe failed: %d\n", ret); |
1564 | 1568 | ||
1565 | return ret; | 1569 | return ret; |