media: mediatek: vcodec: Constify struct vb2_ops
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 16 Jun 2024 06:29:53 +0000 (08:29 +0200)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 28 Aug 2024 08:01:10 +0000 (10:01 +0200)
"struct vb2_ops" are not modified in this driver.

Constifying this structure moves some data to a read-only section, so
increase overall security.

On a x86_64, with allmodconfig:
Before:
======
   text    data     bss     dec     hex filename
  18059    3096      16   21171    52b3 drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateful.o

After:
=====
   text    data     bss     dec     hex filename
  18171    2968      16   21155    52a3 drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateful.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateful.c
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c

index 11ca2c2fbaade84ab51e6fab53142d78323fc63f..e62c1c18758bb18f518de88633995bcf4955781d 100644 (file)
@@ -595,7 +595,7 @@ static void mtk_init_vdec_params(struct mtk_vcodec_dec_ctx *ctx)
        }
 }
 
-static struct vb2_ops mtk_vdec_frame_vb2_ops = {
+static const struct vb2_ops mtk_vdec_frame_vb2_ops = {
        .queue_setup = vb2ops_vdec_queue_setup,
        .buf_prepare = vb2ops_vdec_buf_prepare,
        .wait_prepare = vb2_ops_wait_prepare,
index b903e39fee8928beab938fc5163d3114735ef645..3307dc15fc1dfee96362239f2096190c57a0be10 100644 (file)
@@ -854,7 +854,7 @@ static int vb2ops_vdec_out_buf_validate(struct vb2_buffer *vb)
        return 0;
 }
 
-static struct vb2_ops mtk_vdec_request_vb2_ops = {
+static const struct vb2_ops mtk_vdec_request_vb2_ops = {
        .queue_setup    = vb2ops_vdec_queue_setup,
        .wait_prepare   = vb2_ops_wait_prepare,
        .wait_finish    = vb2_ops_wait_finish,