summaryrefslogtreecommitdiff
path: root/drivers/media/v4l2-core/v4l2-flash-led-class.c
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2016-10-05 04:13:10 -0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-10-24 18:36:28 -0200
commit079933dbcb02132cc48ba052882fe0a9e3b0b762 (patch)
tree6064c74276450d1b18d198fad0eb4dfa86f737cd /drivers/media/v4l2-core/v4l2-flash-led-class.c
parentc762ff1f7e3b09293c22ce62135ef550c1b3327c (diff)
[media] v4l: flash led class: Fix of_node release in probe() error path
The sub-device's OF node was used (of_node_get()) if it was set, but device's OF node was always put. Fix this. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/v4l2-core/v4l2-flash-led-class.c')
-rw-r--r--drivers/media/v4l2-core/v4l2-flash-led-class.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c
index ae7544d5469a..6b31c0aad84a 100644
--- a/drivers/media/v4l2-core/v4l2-flash-led-class.c
+++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c
@@ -638,7 +638,7 @@ struct v4l2_flash *v4l2_flash_init(
v4l2_flash->iled_cdev = iled_cdev;
v4l2_flash->ops = ops;
sd->dev = dev;
- sd->of_node = of_node;
+ sd->of_node = of_node ? of_node : led_cdev->dev->of_node;
v4l2_subdev_init(sd, &v4l2_flash_subdev_ops);
sd->internal_ops = &v4l2_flash_subdev_internal_ops;
sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
@@ -654,10 +654,7 @@ struct v4l2_flash *v4l2_flash_init(
if (ret < 0)
goto err_init_controls;
- if (sd->of_node)
- of_node_get(sd->of_node);
- else
- of_node_get(led_cdev->dev->of_node);
+ of_node_get(sd->of_node);
ret = v4l2_async_register_subdev(sd);
if (ret < 0)
@@ -666,7 +663,7 @@ struct v4l2_flash *v4l2_flash_init(
return v4l2_flash;
err_async_register_sd:
- of_node_put(led_cdev->dev->of_node);
+ of_node_put(sd->of_node);
v4l2_ctrl_handler_free(sd->ctrl_handler);
err_init_controls:
media_entity_cleanup(&sd->entity);
@@ -688,10 +685,7 @@ void v4l2_flash_release(struct v4l2_flash *v4l2_flash)
v4l2_async_unregister_subdev(sd);
- if (sd->of_node)
- of_node_put(sd->of_node);
- else
- of_node_put(led_cdev->dev->of_node);
+ of_node_put(sd->of_node);
v4l2_ctrl_handler_free(sd->ctrl_handler);
media_entity_cleanup(&sd->entity);