Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1714479 > unrolled thread

[PATCH] media: venus: fix duplicated code for different branches

Started by"Gustavo A. R. Silva" <gustavo@embeddedor.com>
First post2017-08-18 01:20 +0200
Last post2017-08-23 17:20 +0200
Articles 9 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] media: venus: fix duplicated code for different branches "Gustavo A. R. Silva" <gustavo@embeddedor.com> - 2017-08-18 01:20 +0200
    Re: [PATCH] media: venus: fix duplicated code for different branches Hans Verkuil <hverkuil@xs4all.nl> - 2017-08-18 09:00 +0200
    Re: [PATCH] media: venus: fix duplicated code for different branches Stanimir Varbanov <stanimir.varbanov@linaro.org> - 2017-08-18 10:00 +0200
      Re: [PATCH] media: venus: fix duplicated code for different branches "Gustavo A. R. Silva" <gustavo@embeddedor.com> - 2017-08-18 18:00 +0200
        [PATCH v2] venus: fix copy/paste error in return_buf_error "Gustavo A. R. Silva" <gustavo@embeddedor.com> - 2017-08-18 18:10 +0200
          Re: [PATCH v2] venus: fix copy/paste error in return_buf_error Stanimir Varbanov <svarbanov@mm-sol.com> - 2017-08-21 11:20 +0200
            Re: [PATCH v2] venus: fix copy/paste error in return_buf_error "Gustavo A. R. Silva" <gustavo@embeddedor.com> - 2017-08-22 21:30 +0200
          Re: [PATCH v2] venus: fix copy/paste error in return_buf_error Stanimir Varbanov <stanimir.varbanov@linaro.org> - 2017-08-23 15:00 +0200
            Re: [PATCH v2] venus: fix copy/paste error in return_buf_error Stanimir Varbanov <stanimir.varbanov@linaro.org> - 2017-08-23 17:20 +0200

#1714479 — [PATCH] media: venus: fix duplicated code for different branches

From"Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date2017-08-18 01:20 +0200
Subject[PATCH] media: venus: fix duplicated code for different branches
Message-ID<ufCf0-3iO-11@gated-at.bofh.it>
Refactor code in order to avoid identical code for different branches.

This issue was detected with the help of Coccinelle.

Addresses-Coverity-ID: 1415317
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
This code was reported by Coverity and it was tested by compilation only.
Please, verify if this is an actual bug.

 drivers/media/platform/qcom/venus/helpers.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
index 5f4434c..8a5c467 100644
--- a/drivers/media/platform/qcom/venus/helpers.c
+++ b/drivers/media/platform/qcom/venus/helpers.c
@@ -240,11 +240,7 @@ static void return_buf_error(struct venus_inst *inst,
 {
 	struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx;
 
-	if (vbuf->vb2_buf.type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
-		v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
-	else
-		v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
-
+	v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
 	v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
 }
 
-- 
2.5.0

[toc] | [next] | [standalone]


#1714615

FromHans Verkuil <hverkuil@xs4all.nl>
Date2017-08-18 09:00 +0200
Message-ID<ufJqa-896-3@gated-at.bofh.it>
In reply to#1714479
Stanimir, please review this! I suspect that this is the wrong fix and
that the first v4l2_m2m_src_buf_remove_by_buf should be
v4l2_m2m_dst_buf_remove_by_buf instead.

Regards,

	Hans

On 08/18/2017 01:12 AM, Gustavo A. R. Silva wrote:
> Refactor code in order to avoid identical code for different branches.
> 
> This issue was detected with the help of Coccinelle.
> 
> Addresses-Coverity-ID: 1415317
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> This code was reported by Coverity and it was tested by compilation only.
> Please, verify if this is an actual bug.
> 
>  drivers/media/platform/qcom/venus/helpers.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
> index 5f4434c..8a5c467 100644
> --- a/drivers/media/platform/qcom/venus/helpers.c
> +++ b/drivers/media/platform/qcom/venus/helpers.c
> @@ -240,11 +240,7 @@ static void return_buf_error(struct venus_inst *inst,
>  {
>  	struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx;
>  
> -	if (vbuf->vb2_buf.type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
> -		v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
> -	else
> -		v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
> -
> +	v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
>  	v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
>  }
>  
> 

[toc] | [prev] | [next] | [standalone]


#1714657

FromStanimir Varbanov <stanimir.varbanov@linaro.org>
Date2017-08-18 10:00 +0200
Message-ID<ufKmf-tm-19@gated-at.bofh.it>
In reply to#1714479
Hi Gustavo,

On 08/18/2017 02:12 AM, Gustavo A. R. Silva wrote:
> Refactor code in order to avoid identical code for different branches.
> 
> This issue was detected with the help of Coccinelle.
> 
> Addresses-Coverity-ID: 1415317
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> This code was reported by Coverity and it was tested by compilation only.
> Please, verify if this is an actual bug.

Yes looks like copy/paste error, and yes it is a bug.

> 
>  drivers/media/platform/qcom/venus/helpers.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
> index 5f4434c..8a5c467 100644
> --- a/drivers/media/platform/qcom/venus/helpers.c
> +++ b/drivers/media/platform/qcom/venus/helpers.c
> @@ -240,11 +240,7 @@ static void return_buf_error(struct venus_inst *inst,
>  {
>  	struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx;
>  
> -	if (vbuf->vb2_buf.type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
> -		v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
> -	else
> -		v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);

the correct fix must replace the second v4l2_m2m_src_* with v4l2_m2m_dst_*.

> -
> +	v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
>  	v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
>  }
>  
> 

-- 
regards,
Stan

[toc] | [prev] | [next] | [standalone]


#1715280

From"Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date2017-08-18 18:00 +0200
Message-ID<ufRQK-5Ky-3@gated-at.bofh.it>
In reply to#1714657
Hi Stanimir,

On 08/18/2017 02:52 AM, Stanimir Varbanov wrote:
> Hi Gustavo,
>
> On 08/18/2017 02:12 AM, Gustavo A. R. Silva wrote:
>> Refactor code in order to avoid identical code for different branches.
>>
>> This issue was detected with the help of Coccinelle.
>>
>> Addresses-Coverity-ID: 1415317
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>> ---
>> This code was reported by Coverity and it was tested by compilation only.
>> Please, verify if this is an actual bug.
>
> Yes looks like copy/paste error, and yes it is a bug.
>

Thank you for reviewing it.

>>
>>  drivers/media/platform/qcom/venus/helpers.c | 6 +-----
>>  1 file changed, 1 insertion(+), 5 deletions(-)
>>
>> diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
>> index 5f4434c..8a5c467 100644
>> --- a/drivers/media/platform/qcom/venus/helpers.c
>> +++ b/drivers/media/platform/qcom/venus/helpers.c
>> @@ -240,11 +240,7 @@ static void return_buf_error(struct venus_inst *inst,
>>  {
>>  	struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx;
>>
>> -	if (vbuf->vb2_buf.type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
>> -		v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
>> -	else
>> -		v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
>
> the correct fix must replace the second v4l2_m2m_src_* with v4l2_m2m_dst_*.
>

I'll send a patch to fix this bug shortly

>> -
>> +	v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
>>  	v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
>>  }
>>
>>
>

Thanks!
-- 
Gustavo A. R. Silva

[toc] | [prev] | [next] | [standalone]


#1715289 — [PATCH v2] venus: fix copy/paste error in return_buf_error

From"Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date2017-08-18 18:10 +0200
Subject[PATCH v2] venus: fix copy/paste error in return_buf_error
Message-ID<ufS0q-63B-23@gated-at.bofh.it>
In reply to#1715280
Call function v4l2_m2m_dst_buf_remove_by_buf() instead of
v4l2_m2m_src_buf_remove_by_buf()

Addresses-Coverity-ID: 1415317
Cc: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
Changes in v2:
 Stanimir Varbanov confirmed this is a bug. The correct fix is to call
 function v4l2_m2m_dst_buf_remove_by_buf instead of function
 v4l2_m2m_src_buf_remove_by_buf in the _else_ branch.

 drivers/media/platform/qcom/venus/helpers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
index 5f4434c..2d61879 100644
--- a/drivers/media/platform/qcom/venus/helpers.c
+++ b/drivers/media/platform/qcom/venus/helpers.c
@@ -243,7 +243,7 @@ static void return_buf_error(struct venus_inst *inst,
 	if (vbuf->vb2_buf.type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
 		v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
 	else
-		v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
+		v4l2_m2m_dst_buf_remove_by_buf(m2m_ctx, vbuf);
 
 	v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
 }
-- 
2.5.0

[toc] | [prev] | [next] | [standalone]


#1716222 — Re: [PATCH v2] venus: fix copy/paste error in return_buf_error

FromStanimir Varbanov <svarbanov@mm-sol.com>
Date2017-08-21 11:20 +0200
SubjectRe: [PATCH v2] venus: fix copy/paste error in return_buf_error
Message-ID<ugR2i-2uy-13@gated-at.bofh.it>
In reply to#1715289
Thanks Gustavo!

On 08/18/2017 07:07 PM, Gustavo A. R. Silva wrote:
> Call function v4l2_m2m_dst_buf_remove_by_buf() instead of
> v4l2_m2m_src_buf_remove_by_buf()
> 
> Addresses-Coverity-ID: 1415317
> Cc: Stanimir Varbanov <stanimir.varbanov@linaro.org>
> Cc: Hans Verkuil <hverkuil@xs4all.nl>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> Changes in v2:
>  Stanimir Varbanov confirmed this is a bug. The correct fix is to call
>  function v4l2_m2m_dst_buf_remove_by_buf instead of function
>  v4l2_m2m_src_buf_remove_by_buf in the _else_ branch.
> 
>  drivers/media/platform/qcom/venus/helpers.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Acked-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>

> 
> diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
> index 5f4434c..2d61879 100644
> --- a/drivers/media/platform/qcom/venus/helpers.c
> +++ b/drivers/media/platform/qcom/venus/helpers.c
> @@ -243,7 +243,7 @@ static void return_buf_error(struct venus_inst *inst,
>  	if (vbuf->vb2_buf.type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
>  		v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
>  	else
> -		v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
> +		v4l2_m2m_dst_buf_remove_by_buf(m2m_ctx, vbuf);
>  
>  	v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
>  }
> 

-- 
regards,
Stan

[toc] | [prev] | [next] | [standalone]


#1717739 — Re: [PATCH v2] venus: fix copy/paste error in return_buf_error

From"Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date2017-08-22 21:30 +0200
SubjectRe: [PATCH v2] venus: fix copy/paste error in return_buf_error
Message-ID<uhn2a-6Mv-35@gated-at.bofh.it>
In reply to#1716222

On 08/21/2017 04:14 AM, Stanimir Varbanov wrote:
> Thanks Gustavo!
>

Glad to help. :)

> On 08/18/2017 07:07 PM, Gustavo A. R. Silva wrote:
>> Call function v4l2_m2m_dst_buf_remove_by_buf() instead of
>> v4l2_m2m_src_buf_remove_by_buf()
>>
>> Addresses-Coverity-ID: 1415317
>> Cc: Stanimir Varbanov <stanimir.varbanov@linaro.org>
>> Cc: Hans Verkuil <hverkuil@xs4all.nl>
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>> ---
>> Changes in v2:
>>  Stanimir Varbanov confirmed this is a bug. The correct fix is to call
>>  function v4l2_m2m_dst_buf_remove_by_buf instead of function
>>  v4l2_m2m_src_buf_remove_by_buf in the _else_ branch.
>>
>>  drivers/media/platform/qcom/venus/helpers.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> Acked-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
>
>>
>> diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
>> index 5f4434c..2d61879 100644
>> --- a/drivers/media/platform/qcom/venus/helpers.c
>> +++ b/drivers/media/platform/qcom/venus/helpers.c
>> @@ -243,7 +243,7 @@ static void return_buf_error(struct venus_inst *inst,
>>  	if (vbuf->vb2_buf.type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
>>  		v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
>>  	else
>> -		v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
>> +		v4l2_m2m_dst_buf_remove_by_buf(m2m_ctx, vbuf);
>>
>>  	v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
>>  }
>>
>

-- 
Gustavo A. R. Silva

[toc] | [prev] | [next] | [standalone]


#1718336 — Re: [PATCH v2] venus: fix copy/paste error in return_buf_error

FromStanimir Varbanov <stanimir.varbanov@linaro.org>
Date2017-08-23 15:00 +0200
SubjectRe: [PATCH v2] venus: fix copy/paste error in return_buf_error
Message-ID<uhDqi-DY-19@gated-at.bofh.it>
In reply to#1715289
Gustavo,

could you resend the patch with the Acked-by and Cc stable kernel.

On 08/18/2017 07:07 PM, Gustavo A. R. Silva wrote:
> Call function v4l2_m2m_dst_buf_remove_by_buf() instead of
> v4l2_m2m_src_buf_remove_by_buf()
> 
> Addresses-Coverity-ID: 1415317
> Cc: Stanimir Varbanov <stanimir.varbanov@linaro.org>
> Cc: Hans Verkuil <hverkuil@xs4all.nl>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> Changes in v2:
>  Stanimir Varbanov confirmed this is a bug. The correct fix is to call
>  function v4l2_m2m_dst_buf_remove_by_buf instead of function
>  v4l2_m2m_src_buf_remove_by_buf in the _else_ branch.
> 
>  drivers/media/platform/qcom/venus/helpers.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
> index 5f4434c..2d61879 100644
> --- a/drivers/media/platform/qcom/venus/helpers.c
> +++ b/drivers/media/platform/qcom/venus/helpers.c
> @@ -243,7 +243,7 @@ static void return_buf_error(struct venus_inst *inst,
>  	if (vbuf->vb2_buf.type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
>  		v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
>  	else
> -		v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
> +		v4l2_m2m_dst_buf_remove_by_buf(m2m_ctx, vbuf);
>  
>  	v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
>  }
> 

-- 
regards,
Stan

[toc] | [prev] | [next] | [standalone]


#1718443 — Re: [PATCH v2] venus: fix copy/paste error in return_buf_error

FromStanimir Varbanov <stanimir.varbanov@linaro.org>
Date2017-08-23 17:20 +0200
SubjectRe: [PATCH v2] venus: fix copy/paste error in return_buf_error
Message-ID<uhFBL-2c7-11@gated-at.bofh.it>
In reply to#1718336
On 08/23/2017 03:59 PM, Stanimir Varbanov wrote:
> Gustavo,
> 
> could you resend the patch with the Acked-by and Cc stable kernel.

No need to resend, sorry for the noise.

-- 
regards,
Stan

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web