diff options
author | Sylwester Nawrocki <s.nawrocki@samsung.com> | 2012-11-22 04:17:19 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-11-26 15:29:31 -0500 |
commit | 97d66c47277fc801bc1ee93559a848057181ea55 (patch) | |
tree | 38e5b038cd68529b9fb1a3bfedf2f2ac4f06a9e6 | |
parent | 86163adb8125a4ce85e0b23a50be82bd8c0daf95 (diff) |
[media] s5p-fimc: Prevent race conditions during subdevs registration
Make sure when fimc and fimc-lite capture video node is registered
it has valid pipeline_ops assigned to it. Otherwise when a video
node is opened right after is was registered there, might be an
attempt to use ops that are just being assigned, after function
v4l2_device_register_subdev() returns.
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/platform/s5p-fimc/fimc-capture.c | 7 | ||||
-rw-r--r-- | drivers/media/platform/s5p-fimc/fimc-lite.c | 3 | ||||
-rw-r--r-- | drivers/media/platform/s5p-fimc/fimc-mdevice.c | 4 |
3 files changed, 11 insertions, 3 deletions
diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c b/drivers/media/platform/s5p-fimc/fimc-capture.c index 3d39d97abaa5..3fc896b8eeae 100644 --- a/drivers/media/platform/s5p-fimc/fimc-capture.c +++ b/drivers/media/platform/s5p-fimc/fimc-capture.c | |||
@@ -1774,9 +1774,13 @@ static int fimc_capture_subdev_registered(struct v4l2_subdev *sd) | |||
1774 | if (ret) | 1774 | if (ret) |
1775 | return ret; | 1775 | return ret; |
1776 | 1776 | ||
1777 | fimc->pipeline_ops = v4l2_get_subdev_hostdata(sd); | ||
1778 | |||
1777 | ret = fimc_register_capture_device(fimc, sd->v4l2_dev); | 1779 | ret = fimc_register_capture_device(fimc, sd->v4l2_dev); |
1778 | if (ret) | 1780 | if (ret) { |
1779 | fimc_unregister_m2m_device(fimc); | 1781 | fimc_unregister_m2m_device(fimc); |
1782 | fimc->pipeline_ops = NULL; | ||
1783 | } | ||
1780 | 1784 | ||
1781 | return ret; | 1785 | return ret; |
1782 | } | 1786 | } |
@@ -1793,6 +1797,7 @@ static void fimc_capture_subdev_unregistered(struct v4l2_subdev *sd) | |||
1793 | if (video_is_registered(&fimc->vid_cap.vfd)) { | 1797 | if (video_is_registered(&fimc->vid_cap.vfd)) { |
1794 | video_unregister_device(&fimc->vid_cap.vfd); | 1798 | video_unregister_device(&fimc->vid_cap.vfd); |
1795 | media_entity_cleanup(&fimc->vid_cap.vfd.entity); | 1799 | media_entity_cleanup(&fimc->vid_cap.vfd.entity); |
1800 | fimc->pipeline_ops = NULL; | ||
1796 | } | 1801 | } |
1797 | kfree(fimc->vid_cap.ctx); | 1802 | kfree(fimc->vid_cap.ctx); |
1798 | fimc->vid_cap.ctx = NULL; | 1803 | fimc->vid_cap.ctx = NULL; |
diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c b/drivers/media/platform/s5p-fimc/fimc-lite.c index 9db246bed841..23f203e8a7d3 100644 --- a/drivers/media/platform/s5p-fimc/fimc-lite.c +++ b/drivers/media/platform/s5p-fimc/fimc-lite.c | |||
@@ -1263,10 +1263,12 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev *sd) | |||
1263 | return ret; | 1263 | return ret; |
1264 | 1264 | ||
1265 | video_set_drvdata(vfd, fimc); | 1265 | video_set_drvdata(vfd, fimc); |
1266 | fimc->pipeline_ops = v4l2_get_subdev_hostdata(sd); | ||
1266 | 1267 | ||
1267 | ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1); | 1268 | ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1); |
1268 | if (ret < 0) { | 1269 | if (ret < 0) { |
1269 | media_entity_cleanup(&vfd->entity); | 1270 | media_entity_cleanup(&vfd->entity); |
1271 | fimc->pipeline_ops = NULL; | ||
1270 | return ret; | 1272 | return ret; |
1271 | } | 1273 | } |
1272 | 1274 | ||
@@ -1285,6 +1287,7 @@ static void fimc_lite_subdev_unregistered(struct v4l2_subdev *sd) | |||
1285 | if (video_is_registered(&fimc->vfd)) { | 1287 | if (video_is_registered(&fimc->vfd)) { |
1286 | video_unregister_device(&fimc->vfd); | 1288 | video_unregister_device(&fimc->vfd); |
1287 | media_entity_cleanup(&fimc->vfd.entity); | 1289 | media_entity_cleanup(&fimc->vfd.entity); |
1290 | fimc->pipeline_ops = NULL; | ||
1288 | } | 1291 | } |
1289 | } | 1292 | } |
1290 | 1293 | ||
diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c b/drivers/media/platform/s5p-fimc/fimc-mdevice.c index 38ea4d143a49..0531ab70a94c 100644 --- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c +++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c | |||
@@ -352,6 +352,7 @@ static int fimc_register_callback(struct device *dev, void *p) | |||
352 | 352 | ||
353 | sd = &fimc->vid_cap.subdev; | 353 | sd = &fimc->vid_cap.subdev; |
354 | sd->grp_id = FIMC_GROUP_ID; | 354 | sd->grp_id = FIMC_GROUP_ID; |
355 | v4l2_set_subdev_hostdata(sd, (void *)&fimc_pipeline_ops); | ||
355 | 356 | ||
356 | ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); | 357 | ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); |
357 | if (ret) { | 358 | if (ret) { |
@@ -360,7 +361,6 @@ static int fimc_register_callback(struct device *dev, void *p) | |||
360 | return ret; | 361 | return ret; |
361 | } | 362 | } |
362 | 363 | ||
363 | fimc->pipeline_ops = &fimc_pipeline_ops; | ||
364 | fmd->fimc[fimc->id] = fimc; | 364 | fmd->fimc[fimc->id] = fimc; |
365 | return 0; | 365 | return 0; |
366 | } | 366 | } |
@@ -375,6 +375,7 @@ static int fimc_lite_register_callback(struct device *dev, void *p) | |||
375 | return 0; | 375 | return 0; |
376 | 376 | ||
377 | fimc->subdev.grp_id = FLITE_GROUP_ID; | 377 | fimc->subdev.grp_id = FLITE_GROUP_ID; |
378 | v4l2_set_subdev_hostdata(&fimc->subdev, (void *)&fimc_pipeline_ops); | ||
378 | 379 | ||
379 | ret = v4l2_device_register_subdev(&fmd->v4l2_dev, &fimc->subdev); | 380 | ret = v4l2_device_register_subdev(&fmd->v4l2_dev, &fimc->subdev); |
380 | if (ret) { | 381 | if (ret) { |
@@ -384,7 +385,6 @@ static int fimc_lite_register_callback(struct device *dev, void *p) | |||
384 | return ret; | 385 | return ret; |
385 | } | 386 | } |
386 | 387 | ||
387 | fimc->pipeline_ops = &fimc_pipeline_ops; | ||
388 | fmd->fimc_lite[fimc->index] = fimc; | 388 | fmd->fimc_lite[fimc->index] = fimc; |
389 | return 0; | 389 | return 0; |
390 | } | 390 | } |