Commit c06950ae authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Mauro Carvalho Chehab

V4L/DVB (12160): soc-camera: fix missing clean up on error path

If soc_camera_init_user_formats() fails in soc_camera_probe(), we have to call
client's .remove() method to unregister the video device.
Reported-by: default avatarKuninori Morimoto <morimoto.kuninori@renesas.com>
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 14df2cce
...@@ -877,8 +877,11 @@ static int soc_camera_probe(struct device *dev) ...@@ -877,8 +877,11 @@ static int soc_camera_probe(struct device *dev)
(unsigned short)~0; (unsigned short)~0;
ret = soc_camera_init_user_formats(icd); ret = soc_camera_init_user_formats(icd);
if (ret < 0) if (ret < 0) {
if (icd->ops->remove)
icd->ops->remove(icd);
goto eiufmt; goto eiufmt;
}
icd->height = DEFAULT_HEIGHT; icd->height = DEFAULT_HEIGHT;
icd->width = DEFAULT_WIDTH; icd->width = DEFAULT_WIDTH;
...@@ -902,8 +905,10 @@ static int soc_camera_remove(struct device *dev) ...@@ -902,8 +905,10 @@ static int soc_camera_remove(struct device *dev)
{ {
struct soc_camera_device *icd = to_soc_camera_dev(dev); struct soc_camera_device *icd = to_soc_camera_dev(dev);
mutex_lock(&icd->video_lock);
if (icd->ops->remove) if (icd->ops->remove)
icd->ops->remove(icd); icd->ops->remove(icd);
mutex_unlock(&icd->video_lock);
soc_camera_free_user_formats(icd); soc_camera_free_user_formats(icd);
...@@ -1145,6 +1150,7 @@ evidallocd: ...@@ -1145,6 +1150,7 @@ evidallocd:
} }
EXPORT_SYMBOL(soc_camera_video_start); EXPORT_SYMBOL(soc_camera_video_start);
/* Called from client .remove() methods with .video_lock held */
void soc_camera_video_stop(struct soc_camera_device *icd) void soc_camera_video_stop(struct soc_camera_device *icd)
{ {
struct video_device *vdev = icd->vdev; struct video_device *vdev = icd->vdev;
...@@ -1154,10 +1160,8 @@ void soc_camera_video_stop(struct soc_camera_device *icd) ...@@ -1154,10 +1160,8 @@ void soc_camera_video_stop(struct soc_camera_device *icd)
if (!icd->dev.parent || !vdev) if (!icd->dev.parent || !vdev)
return; return;
mutex_lock(&icd->video_lock);
video_unregister_device(vdev); video_unregister_device(vdev);
icd->vdev = NULL; icd->vdev = NULL;
mutex_unlock(&icd->video_lock);
} }
EXPORT_SYMBOL(soc_camera_video_stop); EXPORT_SYMBOL(soc_camera_video_stop);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment