media: mediatek: vcodec: Fix VP8 stateless decoder smatch warning
PATCH 1/1 media: mediatek: vcodec: Fix VP8 stateless decoder smatch warning
From: Yunfei Dong <[email protected]>
[ Upstream commit b113bc7c0e83b32f4dd2d291a2b6c4803e0a2c44 ]
Fix a smatch static checker warning on vdec_vp8_req_if.c. Which leads to a kernel crash when fb is NULL.
---
Build test passed.
--- .../platform/mediatek/vcodec/vdec/vdec_vp8_req_if.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_req_if.c +7 -3
@@ -336,14 +336,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_vcodec_err (inst,"fb buffer is NULL" ); +return -ENOMEM ; + } - 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 = 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 = fb->base_c.dma_addr; inst->vsi->dec.bs_dma = (u64 )bs->dma_addr; inst->vsi->dec.bs_sz = bs->size;
Signature · 1 line
2.34.1
[ Sasha's backport helper bot ]
Hi,
The upstream commit SHA1 provided is correct: b113bc7c0e83b32f4dd2d291a2b6c4803e0a2c44
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: dbe5b7373801)
Note: The patch differs from the upstream commit:
---
1: b113bc7c0e83b ! 1: 7220bc28bdb34 media: mediatek: vcodec: Fix VP8 stateless decoder smatch warning
@@ Metadata
## Commit message ##
media: mediatek: vcodec: Fix VP8 stateless decoder smatch warning
+ [ Upstream commit b113bc7c0e83b32f4dd2d291a2b6c4803e0a2c44 ]
+
Fix a smatch static checker warning on vdec_vp8_req_if.c. Which leads to a kernel crash when fb is NULL.
@@ Commit message
+ Signed-off-by: Bin Lan <[email protected]>
+ Signed-off-by: He Zhe <[email protected]>
- ## drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c ##
-@@ drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c: static int vdec_vp8_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
+ ## drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_req_if.c ##
+@@ drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_req_if.c: 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");
++ mtk_vcodec_err(inst, "fb buffer is NULL");
+ return -ENOMEM;
+ }
---
Results of testing on various branches:
| Branch | Patch Apply | Build Test | |---------------------------|-------------|------------| | stable/linux-6.1.y | Success | Success |