]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: vimc: Constify vimc_ent_type structures
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Wed, 24 Apr 2024 23:57:34 +0000 (02:57 +0300)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 26 Jun 2024 14:39:34 +0000 (16:39 +0200)
The vimc_ent_type structure contains static pointers to functions, and
no other information that need to be modified after initialization. Make
them const to avoid the risk of arbitrary code execution following an
overflow that would overwrite the structure's contents.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/test-drivers/vimc/vimc-capture.c
drivers/media/test-drivers/vimc/vimc-common.h
drivers/media/test-drivers/vimc/vimc-debayer.c
drivers/media/test-drivers/vimc/vimc-lens.c
drivers/media/test-drivers/vimc/vimc-scaler.c
drivers/media/test-drivers/vimc/vimc-sensor.c

index ba7550b8ba7ec3d22c65095312355b708177ea70..89506ae009016779807768159e78711dc53fd721 100644 (file)
@@ -494,7 +494,7 @@ err_free_vcapture:
        return ERR_PTR(ret);
 }
 
-struct vimc_ent_type vimc_capture_type = {
+const struct vimc_ent_type vimc_capture_type = {
        .add = vimc_capture_add,
        .unregister = vimc_capture_unregister,
        .release = vimc_capture_release
index 7641a101a728e3e4b15aefaee2e43accba09bb96..6a76717e038498f95eed7dfe2a61ff6d36950105 100644 (file)
@@ -156,7 +156,7 @@ struct vimc_ent_type {
  */
 struct vimc_ent_config {
        const char *name;
-       struct vimc_ent_type *type;
+       const struct vimc_ent_type *type;
 };
 
 /**
@@ -167,11 +167,11 @@ struct vimc_ent_config {
  */
 bool vimc_is_source(struct media_entity *ent);
 
-extern struct vimc_ent_type vimc_sensor_type;
-extern struct vimc_ent_type vimc_debayer_type;
-extern struct vimc_ent_type vimc_scaler_type;
-extern struct vimc_ent_type vimc_capture_type;
-extern struct vimc_ent_type vimc_lens_type;
+extern const struct vimc_ent_type vimc_sensor_type;
+extern const struct vimc_ent_type vimc_debayer_type;
+extern const struct vimc_ent_type vimc_scaler_type;
+extern const struct vimc_ent_type vimc_capture_type;
+extern const struct vimc_ent_type vimc_lens_type;
 
 /**
  * vimc_pix_map_by_index - get vimc_pix_map struct by its index
index e1bf6db730503f4dedbf1b6b636a7cc35df8677c..e2f12a7fb58fd2a4a71daac1b20c7c366959f27b 100644 (file)
@@ -622,7 +622,7 @@ err_free_vdebayer:
        return ERR_PTR(ret);
 }
 
-struct vimc_ent_type vimc_debayer_type = {
+const struct vimc_ent_type vimc_debayer_type = {
        .add = vimc_debayer_add,
        .release = vimc_debayer_release
 };
index 3ce7f4b4d2cc0280d3b12fe5676a4c48f3275506..e7d78fa8ccdbc2b472343a91976675a048bc0976 100644 (file)
@@ -96,7 +96,7 @@ static void vimc_lens_release(struct vimc_ent_device *ved)
        kfree(vlens);
 }
 
-struct vimc_ent_type vimc_lens_type = {
+const struct vimc_ent_type vimc_lens_type = {
        .add = vimc_lens_add,
        .release = vimc_lens_release
 };
index afe13d6af321b3b0a180a5c9e87dc17310782b47..3e32cfb79c648290906f5aa5af60a51e9ce9ef8f 100644 (file)
@@ -442,7 +442,7 @@ static struct vimc_ent_device *vimc_scaler_add(struct vimc_device *vimc,
        return &vscaler->ved;
 }
 
-struct vimc_ent_type vimc_scaler_type = {
+const struct vimc_ent_type vimc_scaler_type = {
        .add = vimc_scaler_add,
        .release = vimc_scaler_release
 };
index b535b3ffecff9914df47fd71151ba2b2a7ad309e..11df18332865e5d048740ecf090f857658ab5ef9 100644 (file)
@@ -448,7 +448,7 @@ err_free_vsensor:
        return ERR_PTR(ret);
 }
 
-struct vimc_ent_type vimc_sensor_type = {
+const struct vimc_ent_type vimc_sensor_type = {
        .add = vimc_sensor_add,
        .release = vimc_sensor_release
 };