diff mbox series

media: camss: Clean up received buffers on failed start of streaming

Message ID 20220704094437.468395-1-vladimir.zapolskiy@linaro.org
State Accepted
Commit c8f3582345e6a69da65ab588f7c4c2d1685b0e80
Headers show
Series media: camss: Clean up received buffers on failed start of streaming | expand

Commit Message

Vladimir Zapolskiy July 4, 2022, 9:44 a.m. UTC
It is required to return the received buffers, if streaming can not be
started. For instance media_pipeline_start() may fail with EPIPE, if
a link validation between entities is not passed, and in such a case
a user gets a kernel warning:

  WARNING: CPU: 1 PID: 520 at drivers/media/common/videobuf2/videobuf2-core.c:1592 vb2_start_streaming+0xec/0x160
  <snip>
  Call trace:
   vb2_start_streaming+0xec/0x160
   vb2_core_streamon+0x9c/0x1a0
   vb2_ioctl_streamon+0x68/0xbc
   v4l_streamon+0x30/0x3c
   __video_do_ioctl+0x184/0x3e0
   video_usercopy+0x37c/0x7b0
   video_ioctl2+0x24/0x40
   v4l2_ioctl+0x4c/0x70

The fix is to correct the error path in video_start_streaming() of camss.

Fixes: 0ac2586c410f ("media: camss: Add files which handle the video device nodes")
Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
---
 drivers/media/platform/qcom/camss/camss-video.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Robert Foss July 4, 2022, 2:33 p.m. UTC | #1
On Mon, 4 Jul 2022 at 11:44, Vladimir Zapolskiy
<vladimir.zapolskiy@linaro.org> wrote:
>
> It is required to return the received buffers, if streaming can not be
> started. For instance media_pipeline_start() may fail with EPIPE, if
> a link validation between entities is not passed, and in such a case
> a user gets a kernel warning:
>
>   WARNING: CPU: 1 PID: 520 at drivers/media/common/videobuf2/videobuf2-core.c:1592 vb2_start_streaming+0xec/0x160
>   <snip>
>   Call trace:
>    vb2_start_streaming+0xec/0x160
>    vb2_core_streamon+0x9c/0x1a0
>    vb2_ioctl_streamon+0x68/0xbc
>    v4l_streamon+0x30/0x3c
>    __video_do_ioctl+0x184/0x3e0
>    video_usercopy+0x37c/0x7b0
>    video_ioctl2+0x24/0x40
>    v4l2_ioctl+0x4c/0x70
>
> The fix is to correct the error path in video_start_streaming() of camss.
>
> Fixes: 0ac2586c410f ("media: camss: Add files which handle the video device nodes")
> Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
> ---
>  drivers/media/platform/qcom/camss/camss-video.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
> index b5f12ec5c50c..d272ffa02112 100644
> --- a/drivers/media/platform/qcom/camss/camss-video.c
> +++ b/drivers/media/platform/qcom/camss/camss-video.c
> @@ -495,7 +495,7 @@ static int video_start_streaming(struct vb2_queue *q, unsigned int count)
>
>         ret = media_pipeline_start(&vdev->entity, &video->pipe);
>         if (ret < 0)
> -               return ret;
> +               goto flush_buffers;
>
>         ret = video_check_format(video);
>         if (ret < 0)
> @@ -524,6 +524,7 @@ static int video_start_streaming(struct vb2_queue *q, unsigned int count)
>  error:
>         media_pipeline_stop(&vdev->entity);
>
> +flush_buffers:
>         video->ops->flush_buffers(video, VB2_BUF_STATE_QUEUED);
>
>         return ret;
> --
> 2.33.0
>

Reviewed-by: Robert Foss <robert.foss@linaro.org>
diff mbox series

Patch

diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
index b5f12ec5c50c..d272ffa02112 100644
--- a/drivers/media/platform/qcom/camss/camss-video.c
+++ b/drivers/media/platform/qcom/camss/camss-video.c
@@ -495,7 +495,7 @@  static int video_start_streaming(struct vb2_queue *q, unsigned int count)
 
 	ret = media_pipeline_start(&vdev->entity, &video->pipe);
 	if (ret < 0)
-		return ret;
+		goto flush_buffers;
 
 	ret = video_check_format(video);
 	if (ret < 0)
@@ -524,6 +524,7 @@  static int video_start_streaming(struct vb2_queue *q, unsigned int count)
 error:
 	media_pipeline_stop(&vdev->entity);
 
+flush_buffers:
 	video->ops->flush_buffers(video, VB2_BUF_STATE_QUEUED);
 
 	return ret;