mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] media: mediatek: vcodec: fix vcodec smatch warning
@ 2024-02-29  9:56 Yunfei Dong
  2024-02-29  9:56 ` [PATCH 1/3] media: mediatek: vcodec: fix h264 multi statless decoder " Yunfei Dong
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Yunfei Dong @ 2024-02-29  9:56 UTC (permalink / raw)
  To: Nícolas F . R . A . Prado, Nicolas Dufresne, Hans Verkuil,
	AngeloGioacchino Del Regno, Benjamin Gaignard, Nathan Hebert
  Cc: Hsin-Yi Wang, Fritz Koenig, Daniel Vetter, Steve Cho,
	Yunfei Dong, linux-media, devicetree, linux-kernel,
	linux-arm-kernel, linux-mediatek,
	Project_Global_Chrome_Upstream_Group

Fix below smatch static checker warning from [bug report]:
The patch 397edc703a10: "media: mediatek: vcodec: add h264 decoder
driver for mt8186" from May 12, 2022 (linux-next), leads to the
following (in development) Smatch static checker warning:

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_if.c:351
vdec_h264_slice_decode() potential NULL container_of 'fb'

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c:337
vdec_vp8_slice_decode() potential NULL container_of 'fb'

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c:728
vdec_h264_slice_single_decode() potential NULL container_of 'fb'

---
Yunfei Dong (3):
  media: mediatek: vcodec: fix h264 multi statless decoder smatch
    warning
  media: mediatek: vcodec: fix vp8 stateless decoder smatch warning
  media: mediatek: vcodec: fix h264 stateless decoder smatch warning

 .../mediatek/vcodec/decoder/vdec/vdec_h264_req_if.c    |  9 +++++++--
 .../vcodec/decoder/vdec/vdec_h264_req_multi_if.c       |  9 +++++++--
 .../mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c     | 10 +++++++---
 3 files changed, 21 insertions(+), 7 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] media: mediatek: vcodec: fix h264 multi statless decoder smatch warning
  2024-02-29  9:56 [PATCH 0/3] media: mediatek: vcodec: fix vcodec smatch warning Yunfei Dong
@ 2024-02-29  9:56 ` Yunfei Dong
  2024-04-02  9:50   ` AngeloGioacchino Del Regno
  2024-02-29  9:56 ` [PATCH 2/3] media: mediatek: vcodec: fix vp8 stateless " Yunfei Dong
  2024-02-29  9:56 ` [PATCH 3/3] media: mediatek: vcodec: fix h264 " Yunfei Dong
  2 siblings, 1 reply; 8+ messages in thread
From: Yunfei Dong @ 2024-02-29  9:56 UTC (permalink / raw)
  To: Nícolas F . R . A . Prado, Nicolas Dufresne, Hans Verkuil,
	AngeloGioacchino Del Regno, Benjamin Gaignard, Nathan Hebert
  Cc: Hsin-Yi Wang, Fritz Koenig, Daniel Vetter, Steve Cho,
	Yunfei Dong, linux-media, devicetree, linux-kernel,
	linux-arm-kernel, linux-mediatek,
	Project_Global_Chrome_Upstream_Group

Fix smatch static checker warning for vdec_h264_req_multi_if.c.
Leading to kernel crash when fb is NULL.

Fixes: 397edc703a10 ("media: mediatek: vcodec: add h264 decoder")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
---
 .../vcodec/decoder/vdec/vdec_h264_req_multi_if.c         | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c
index 0e741e0dc8ba..ab8e708e0df1 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c
@@ -724,11 +724,16 @@ static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs
 		return vpu_dec_reset(vpu);
 
 	fb = inst->ctx->dev->vdec_pdata->get_cap_buffer(inst->ctx);
+	if (!fb) {
+		mtk_vdec_err(inst->ctx, "fb buffer is NULL");
+		return -EBUSY;
+	}
+
 	src_buf_info = container_of(bs, struct mtk_video_dec_buf, bs_buffer);
 	dst_buf_info = container_of(fb, struct mtk_video_dec_buf, frame_buffer);
 
-	y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0;
-	c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0;
+	y_fb_dma = (u64)fb->base_y.dma_addr;
+	c_fb_dma = (u64)fb->base_c.dma_addr;
 	mtk_vdec_debug(inst->ctx, "[h264-dec] [%d] y_dma=%llx c_dma=%llx",
 		       inst->ctx->decoded_frame_cnt, y_fb_dma, c_fb_dma);
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/3] media: mediatek: vcodec: fix vp8 stateless decoder smatch warning
  2024-02-29  9:56 [PATCH 0/3] media: mediatek: vcodec: fix vcodec smatch warning Yunfei Dong
  2024-02-29  9:56 ` [PATCH 1/3] media: mediatek: vcodec: fix h264 multi statless decoder " Yunfei Dong
@ 2024-02-29  9:56 ` Yunfei Dong
  2024-02-29  9:56 ` [PATCH 3/3] media: mediatek: vcodec: fix h264 " Yunfei Dong
  2 siblings, 0 replies; 8+ messages in thread
From: Yunfei Dong @ 2024-02-29  9:56 UTC (permalink / raw)
  To: Nícolas F . R . A . Prado, Nicolas Dufresne, Hans Verkuil,
	AngeloGioacchino Del Regno, Benjamin Gaignard, Nathan Hebert
  Cc: Hsin-Yi Wang, Fritz Koenig, Daniel Vetter, Steve Cho,
	Yunfei Dong, linux-media, devicetree, linux-kernel,
	linux-arm-kernel, linux-mediatek,
	Project_Global_Chrome_Upstream_Group

Fix smatch static checker warning for vdec_vp8_req_if.c. Leading
to kernel crash when fb is NULL.

Fixes: 7a7ae26fd458 ("media: mediatek: vcodec: support stateless VP8 decoding")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
---
 .../mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c     | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c
index f677e499fefa..0889517a58e8 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c
@@ -334,14 +334,18 @@ static int vdec_vp8_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
 	src_buf_info = container_of(bs, struct mtk_video_dec_buf, bs_buffer);
 
 	fb = inst->ctx->dev->vdec_pdata->get_cap_buffer(inst->ctx);
-	dst_buf_info = container_of(fb, struct mtk_video_dec_buf, frame_buffer);
+	if (!fb) {
+		mtk_vdec_err(inst->ctx, "fb buffer is NULL");
+		return -EBUSY;
+	}
 
-	y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0;
+	dst_buf_info = container_of(fb, struct mtk_video_dec_buf, frame_buffer);
+	y_fb_dma = (u64)fb->base_y.dma_addr;
 	if (inst->ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes == 1)
 		c_fb_dma = y_fb_dma +
 			inst->ctx->picinfo.buf_w * inst->ctx->picinfo.buf_h;
 	else
-		c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0;
+		c_fb_dma = (u64)fb->base_c.dma_addr;
 
 	inst->vsi->dec.bs_dma = (u64)bs->dma_addr;
 	inst->vsi->dec.bs_sz = bs->size;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/3] media: mediatek: vcodec: fix h264 stateless decoder smatch warning
  2024-02-29  9:56 [PATCH 0/3] media: mediatek: vcodec: fix vcodec smatch warning Yunfei Dong
  2024-02-29  9:56 ` [PATCH 1/3] media: mediatek: vcodec: fix h264 multi statless decoder " Yunfei Dong
  2024-02-29  9:56 ` [PATCH 2/3] media: mediatek: vcodec: fix vp8 stateless " Yunfei Dong
@ 2024-02-29  9:56 ` Yunfei Dong
  2 siblings, 0 replies; 8+ messages in thread
From: Yunfei Dong @ 2024-02-29  9:56 UTC (permalink / raw)
  To: Nícolas F . R . A . Prado, Nicolas Dufresne, Hans Verkuil,
	AngeloGioacchino Del Regno, Benjamin Gaignard, Nathan Hebert
  Cc: Hsin-Yi Wang, Fritz Koenig, Daniel Vetter, Steve Cho,
	Yunfei Dong, linux-media, devicetree, linux-kernel,
	linux-arm-kernel, linux-mediatek,
	Project_Global_Chrome_Upstream_Group

Fix smatch static checker warning for vdec_h264_req_if.c. Leading
to kernel crash when fb is NULL.

Fixes: 06fa5f757dc5 ("media: mtk-vcodec: vdec: support stateless H.264 decoding")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
---
 .../mediatek/vcodec/decoder/vdec/vdec_h264_req_if.c      | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_if.c
index 5600f1df653d..f1c164b644f8 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_if.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_if.c
@@ -347,11 +347,16 @@ static int vdec_h264_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
 		return vpu_dec_reset(vpu);
 
 	fb = inst->ctx->dev->vdec_pdata->get_cap_buffer(inst->ctx);
+	if (!fb) {
+		mtk_vdec_err(inst->ctx, "fb buffer is NULL");
+		return -EBUSY;
+	}
+
 	src_buf_info = container_of(bs, struct mtk_video_dec_buf, bs_buffer);
 	dst_buf_info = container_of(fb, struct mtk_video_dec_buf, frame_buffer);
 
-	y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0;
-	c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0;
+	y_fb_dma = (u64)fb->base_y.dma_addr;
+	c_fb_dma = (u64)fb->base_c.dma_addr;
 
 	mtk_vdec_debug(inst->ctx, "+ [%d] FB y_dma=%llx c_dma=%llx va=%p",
 		       inst->num_nalu, y_fb_dma, c_fb_dma, fb);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] media: mediatek: vcodec: fix h264 multi statless decoder smatch warning
  2024-02-29  9:56 ` [PATCH 1/3] media: mediatek: vcodec: fix h264 multi statless decoder " Yunfei Dong
@ 2024-04-02  9:50   ` AngeloGioacchino Del Regno
  2024-04-03  3:45     ` Yunfei Dong (董云飞)
  0 siblings, 1 reply; 8+ messages in thread
From: AngeloGioacchino Del Regno @ 2024-04-02  9:50 UTC (permalink / raw)
  To: Yunfei Dong, Nícolas F . R . A . Prado, Nicolas Dufresne,
	Hans Verkuil, Benjamin Gaignard, Nathan Hebert
  Cc: Hsin-Yi Wang, Fritz Koenig, Daniel Vetter, Steve Cho,
	linux-media, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, Project_Global_Chrome_Upstream_Group

Il 29/02/24 10:56, Yunfei Dong ha scritto:
> Fix smatch static checker warning for vdec_h264_req_multi_if.c.
> Leading to kernel crash when fb is NULL.
> 
> Fixes: 397edc703a10 ("media: mediatek: vcodec: add h264 decoder")
> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> ---
>   .../vcodec/decoder/vdec/vdec_h264_req_multi_if.c         | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c
> index 0e741e0dc8ba..ab8e708e0df1 100644
> --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c
> @@ -724,11 +724,16 @@ static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs
>   		return vpu_dec_reset(vpu);
>   
>   	fb = inst->ctx->dev->vdec_pdata->get_cap_buffer(inst->ctx);
> +	if (!fb) {
> +		mtk_vdec_err(inst->ctx, "fb buffer is NULL");
> +		return -EBUSY;
> +	}
> +
>   	src_buf_info = container_of(bs, struct mtk_video_dec_buf, bs_buffer);
>   	dst_buf_info = container_of(fb, struct mtk_video_dec_buf, frame_buffer);
>   
> -	y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0;
> -	c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0;

You're changing the behavior here, can you please explain why this change is valid
into the commit description?

Thanks,
Angelo

> +	y_fb_dma = (u64)fb->base_y.dma_addr;
> +	c_fb_dma = (u64)fb->base_c.dma_addr;
>   	mtk_vdec_debug(inst->ctx, "[h264-dec] [%d] y_dma=%llx c_dma=%llx",
>   		       inst->ctx->decoded_frame_cnt, y_fb_dma, c_fb_dma);
>   



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] media: mediatek: vcodec: fix h264 multi statless decoder smatch warning
  2024-04-02  9:50   ` AngeloGioacchino Del Regno
@ 2024-04-03  3:45     ` Yunfei Dong (董云飞)
  2024-05-29 13:14       ` Andrzej Pietrasiewicz
  0 siblings, 1 reply; 8+ messages in thread
From: Yunfei Dong (董云飞) @ 2024-04-03  3:45 UTC (permalink / raw)
  To: nhebert, benjamin.gaignard, nfraprado, angelogioacchino.delregno,
	nicolas.dufresne, hverkuil-cisco
  Cc: linux-kernel, linux-mediatek, frkoenig, stevecho, linux-media,
	devicetree, daniel, Project_Global_Chrome_Upstream_Group, hsinyi,
	linux-arm-kernel

Hi AngeloGioacchino,

Thanks for your reviewing.
On Tue, 2024-04-02 at 11:50 +0200, AngeloGioacchino Del Regno wrote:
> Il 29/02/24 10:56, Yunfei Dong ha scritto:
> > Fix smatch static checker warning for vdec_h264_req_multi_if.c.
> > Leading to kernel crash when fb is NULL.
> > 
> > Fixes: 397edc703a10 ("media: mediatek: vcodec: add h264 decoder")
> > Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> > ---
> >   .../vcodec/decoder/vdec/vdec_h264_req_multi_if.c         | 9
> > +++++++--
> >   1 file changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git
> > a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req
> > _multi_if.c
> > b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req
> > _multi_if.c
> > index 0e741e0dc8ba..ab8e708e0df1 100644
> > ---
> > a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req
> > _multi_if.c
> > +++
> > b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req
> > _multi_if.c
> > @@ -724,11 +724,16 @@ static int vdec_h264_slice_single_decode(void
> > *h_vdec, struct mtk_vcodec_mem *bs
> >   		return vpu_dec_reset(vpu);
> >   
> >   	fb = inst->ctx->dev->vdec_pdata->get_cap_buffer(inst->ctx);
> > +	if (!fb) {
> > +		mtk_vdec_err(inst->ctx, "fb buffer is NULL");
> > +		return -EBUSY;
> > +	}
> > +
> >   	src_buf_info = container_of(bs, struct mtk_video_dec_buf,
> > bs_buffer);
> >   	dst_buf_info = container_of(fb, struct mtk_video_dec_buf,
> > frame_buffer);
> >   
> > -	y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0;
> > -	c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0;
> 
> You're changing the behavior here, can you please explain why this
> change is valid
> into the commit description?
> 
The driver already add the condition to check whether fb is NULL at the
front, no need these two lines again.

> Thanks,
> Angelo
> 
Best Regards,
Yunfei Dong
> > +	y_fb_dma = (u64)fb->base_y.dma_addr;
> > +	c_fb_dma = (u64)fb->base_c.dma_addr;
> >   	mtk_vdec_debug(inst->ctx, "[h264-dec] [%d] y_dma=%llx
> > c_dma=%llx",
> >   		       inst->ctx->decoded_frame_cnt, y_fb_dma,
> > c_fb_dma);
> >   
> 
> 
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] media: mediatek: vcodec: fix h264 multi statless decoder smatch warning
  2024-04-03  3:45     ` Yunfei Dong (董云飞)
@ 2024-05-29 13:14       ` Andrzej Pietrasiewicz
  2024-06-13  9:28         ` Yunfei Dong (董云飞)
  0 siblings, 1 reply; 8+ messages in thread
From: Andrzej Pietrasiewicz @ 2024-05-29 13:14 UTC (permalink / raw)
  To: Yunfei Dong (董云飞),
	nhebert, benjamin.gaignard, nfraprado, angelogioacchino.delregno,
	nicolas.dufresne, hverkuil-cisco
  Cc: linux-kernel, linux-mediatek, frkoenig, stevecho, linux-media,
	devicetree, daniel, Project_Global_Chrome_Upstream_Group, hsinyi,
	linux-arm-kernel

Hi,

W dniu 3.04.2024 o 05:45, Yunfei Dong (董云飞) pisze:
> Hi AngeloGioacchino,
> 
> Thanks for your reviewing.
> On Tue, 2024-04-02 at 11:50 +0200, AngeloGioacchino Del Regno wrote:
>> Il 29/02/24 10:56, Yunfei Dong ha scritto:
>>> Fix smatch static checker warning for vdec_h264_req_multi_if.c.
>>> Leading to kernel crash when fb is NULL.
>>>
>>> Fixes: 397edc703a10 ("media: mediatek: vcodec: add h264 decoder")
>>> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
>>> ---
>>>    .../vcodec/decoder/vdec/vdec_h264_req_multi_if.c         | 9
>>> +++++++--
>>>    1 file changed, 7 insertions(+), 2 deletions(-)
>>>
>>> diff --git
>>> a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req
>>> _multi_if.c
>>> b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req
>>> _multi_if.c
>>> index 0e741e0dc8ba..ab8e708e0df1 100644
>>> ---
>>> a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req
>>> _multi_if.c
>>> +++
>>> b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req
>>> _multi_if.c
>>> @@ -724,11 +724,16 @@ static int vdec_h264_slice_single_decode(void
>>> *h_vdec, struct mtk_vcodec_mem *bs
>>>    		return vpu_dec_reset(vpu);
>>>    
>>>    	fb = inst->ctx->dev->vdec_pdata->get_cap_buffer(inst->ctx);
>>> +	if (!fb) {
>>> +		mtk_vdec_err(inst->ctx, "fb buffer is NULL");
>>> +		return -EBUSY;
>>> +	}
>>> +
>>>    	src_buf_info = container_of(bs, struct mtk_video_dec_buf,
>>> bs_buffer);
>>>    	dst_buf_info = container_of(fb, struct mtk_video_dec_buf,
>>> frame_buffer);
>>>    
>>> -	y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0;
>>> -	c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0;
>>
>> You're changing the behavior here, can you please explain why this
>> change is valid
>> into the commit description?
>>
> The driver already add the condition to check whether fb is NULL at the
> front, no need these two lines again.
> 

Maybe Angelo refers to the function never returning -EBUSY before?
While at it, if fb is a kind of a buffer, why not -ENOMEM
when get_cap_buffer() fails?

Regards,

Andrzej

>> Thanks,
>> Angelo
>>
> Best Regards,
> Yunfei Dong
>>> +	y_fb_dma = (u64)fb->base_y.dma_addr;
>>> +	c_fb_dma = (u64)fb->base_c.dma_addr;
>>>    	mtk_vdec_debug(inst->ctx, "[h264-dec] [%d] y_dma=%llx
>>> c_dma=%llx",
>>>    		       inst->ctx->decoded_frame_cnt, y_fb_dma,
>>> c_fb_dma);
>>>    
>>
>>
>>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] media: mediatek: vcodec: fix h264 multi statless decoder smatch warning
  2024-05-29 13:14       ` Andrzej Pietrasiewicz
@ 2024-06-13  9:28         ` Yunfei Dong (董云飞)
  0 siblings, 0 replies; 8+ messages in thread
From: Yunfei Dong (董云飞) @ 2024-06-13  9:28 UTC (permalink / raw)
  To: andrzej.p
  Cc: linux-mediatek, linux-kernel, frkoenig, stevecho, nhebert,
	linux-media, devicetree, nicolas.dufresne, daniel,
	Project_Global_Chrome_Upstream_Group, hverkuil-cisco,
	benjamin.gaignard, linux-arm-kernel, hsinyi,
	angelogioacchino.delregno, nfraprado

Hi Andrzej,

Thanks for your help to review this patch.

On Wed, 2024-05-29 at 15:14 +0200, Andrzej Pietrasiewicz wrote:
> Hi,
> 
> W dniu 3.04.2024 o 05:45, Yunfei Dong (董云飞) pisze:
> > Hi AngeloGioacchino,
> > 
> > Thanks for your reviewing.
> > On Tue, 2024-04-02 at 11:50 +0200, AngeloGioacchino Del Regno
> > wrote:
> > > Il 29/02/24 10:56, Yunfei Dong ha scritto:
> > > > Fix smatch static checker warning for vdec_h264_req_multi_if.c.
> > > > Leading to kernel crash when fb is NULL.
> > > > 
> > > > Fixes: 397edc703a10 ("media: mediatek: vcodec: add h264
> > > > decoder")
> > > > Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> > > > ---
> > > >    .../vcodec/decoder/vdec/vdec_h264_req_multi_if.c         | 9
> > > > +++++++--
> > > >    1 file changed, 7 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git
> > > > a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264
> > > > _req
> > > > _multi_if.c
> > > > b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264
> > > > _req
> > > > _multi_if.c
> > > > index 0e741e0dc8ba..ab8e708e0df1 100644
> > > > ---
> > > > a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264
> > > > _req
> > > > _multi_if.c
> > > > +++
> > > > b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264
> > > > _req
> > > > _multi_if.c
> > > > @@ -724,11 +724,16 @@ static int
> > > > vdec_h264_slice_single_decode(void
> > > > *h_vdec, struct mtk_vcodec_mem *bs
> > > >    		return vpu_dec_reset(vpu);
> > > >    
> > > >    	fb = inst->ctx->dev->vdec_pdata->get_cap_buffer(inst-
> > > > >ctx);
> > > > +	if (!fb) {
> > > > +		mtk_vdec_err(inst->ctx, "fb buffer is NULL");
> > > > +		return -EBUSY;
> > > > +	}
> > > > +
> > > >    	src_buf_info = container_of(bs, struct
> > > > mtk_video_dec_buf,
> > > > bs_buffer);
> > > >    	dst_buf_info = container_of(fb, struct
> > > > mtk_video_dec_buf,
> > > > frame_buffer);
> > > >    
> > > > -	y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0;
> > > > -	c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0;
> > > 
> > > You're changing the behavior here, can you please explain why
> > > this
> > > change is valid
> > > into the commit description?
> > > 
> > 
> > The driver already add the condition to check whether fb is NULL at
> > the
> > front, no need these two lines again.
> > 
> 
> Maybe Angelo refers to the function never returning -EBUSY before?
> While at it, if fb is a kind of a buffer, why not -ENOMEM
> when get_cap_buffer() fails?
> 
Looks change the return value from EBUSY to ENOMEM much more
reasonable.

> Regards,
> 
> Andrzej
> 
Best Regards,
Yunfei Dong
> > > Thanks,
> > > Angelo
> > > 
> > 
> > Best Regards,
> > Yunfei Dong
> > > > +	y_fb_dma = (u64)fb->base_y.dma_addr;
> > > > +	c_fb_dma = (u64)fb->base_c.dma_addr;
> > > >    	mtk_vdec_debug(inst->ctx, "[h264-dec] [%d] y_dma=%llx
> > > > c_dma=%llx",
> > > >    		       inst->ctx->decoded_frame_cnt, y_fb_dma,
> > > > c_fb_dma);
> > > >    
> > > 
> > > 
> > > 
> 
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-06-13  9:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-29  9:56 [PATCH 0/3] media: mediatek: vcodec: fix vcodec smatch warning Yunfei Dong
2024-02-29  9:56 ` [PATCH 1/3] media: mediatek: vcodec: fix h264 multi statless decoder " Yunfei Dong
2024-04-02  9:50   ` AngeloGioacchino Del Regno
2024-04-03  3:45     ` Yunfei Dong (董云飞)
2024-05-29 13:14       ` Andrzej Pietrasiewicz
2024-06-13  9:28         ` Yunfei Dong (董云飞)
2024-02-29  9:56 ` [PATCH 2/3] media: mediatek: vcodec: fix vp8 stateless " Yunfei Dong
2024-02-29  9:56 ` [PATCH 3/3] media: mediatek: vcodec: fix h264 " Yunfei Dong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®