Skip to contentSkip to conversation

media: mediatek: vcodec: Fix H264 multi stateless decoder smatch warning

PATCH In review [email protected] 2 participants 2 messages Feb 21, 2025 – Feb 22, 2025 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: mediatek: vcodec: Fix H264 multi stateless decoder smatch warning

From: Yunfei Dong <[email protected]>

[ Upstream commit 9be85491619f1953b8a29590ca630be571941ffa ]

Fix a smatch static checker warning on vdec_h264_req_multi_if.c. Which leads to a kernel crash when fb is NULL.

Fixes 397edc703a10 ("media: mediatek: vcodec: add h264 decoder driver for mt8186")

[ drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c is renamed from drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c since 0934d3759615 ("media: mediatek: vcodec: separate decoder and encoder"). The path is changed accordingly to apply the patch on 6.1.y. ]

---
 .../mediatek/vcodec/vdec/vdec_h264_req_multi_if.c        | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c +7 -2
index 999ce7ee5fdc..6952875ca183 100644
@@ -729,11 +729,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_vcodec_err(inst, "fb buffer is NULL");
+		return -ENOMEM;
+	}
+
 	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 = fb->base_y.dma_addr;
+	c_fb_dma = fb->base_c.dma_addr;
 	mtk_vcodec_debug(inst, "[h264-dec] [%d] y_dma=%llx c_dma=%llx",
 			 inst->ctx->decoded_frame_cnt, y_fb_dma, c_fb_dma);
 
Signature · 1 line
2.34.1
maintainer Reviewed-by AngeloGioacchino Del Regno on v1 1/1
#1 lore raw

[ Sasha's backport helper bot ]

Hi,

✅ All tests passed successfully. No issues detected. No action required from the submitter.

The upstream commit SHA1 provided is correct: 9be85491619f1953b8a29590ca630be571941ffa

WARNING: Author mismatch between patch and upstream commit:
Backport author: [email protected]
Commit author: Yunfei Dong<[email protected]>

Status in newer kernel trees:
6.13.y | Present (exact SHA1)
6.12.y | Present (exact SHA1)
6.6.y | Present (different SHA1: 588bcce9e64c)

Note: The patch differs from the upstream commit:
---
1: 9be85491619f1 ! 1: dffd0505449e8 media: mediatek: vcodec: Fix H264 multi stateless decoder smatch warning
@@ Metadata
## Commit message ##
media: mediatek: vcodec: Fix H264 multi stateless decoder smatch warning

+ [ Upstream commit 9be85491619f1953b8a29590ca630be571941ffa ]
+
Fix a smatch static checker warning on vdec_h264_req_multi_if.c. Which leads to a kernel crash when fb is NULL.

@@ Commit message

+ [ drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c
+ is renamed from drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c
+ since 0934d3759615 ("media: mediatek: vcodec: separate decoder and encoder").
+ The path is changed accordingly to apply the patch on 6.1.y. ]
+ Signed-off-by: Wenshan Lan <[email protected]>

- ## drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c ##
-@@ drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c: static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs
+ ## drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c ##
+@@ drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c: 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");
++ mtk_vcodec_err(inst, "fb buffer is NULL");
+ return -ENOMEM;
+ }
+
@@ drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c: st
- c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0;
+ y_fb_dma = fb->base_y.dma_addr;
+ c_fb_dma = 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);
+ mtk_vcodec_debug(inst, "[h264-dec] [%d] y_dma=%llx c_dma=%llx",
+ inst->ctx->decoded_frame_cnt, y_fb_dma, c_fb_dma);

---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.1.y        |  Success    |  Success   |