]> www.infradead.org Git - users/willy/linux.git/commitdiff
drm: Constify drm_driver in drivers that don't modify it
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tue, 15 Dec 2020 20:23:07 +0000 (22:23 +0200)
committerLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tue, 5 Jan 2021 05:20:36 +0000 (07:20 +0200)
A non-const structure containing function pointers is a possible attack
vector. The drm_driver structure is already const in most drivers, but
there are a few exceptions. Constify the structure in the drivers that
don't need to modify at, as a low-hanging fruit. The rest of the drivers
will need a more complex fix.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/arc/arcpgu_drv.c
drivers/gpu/drm/kmb/kmb_drv.c
drivers/gpu/drm/tdfx/tdfx_drv.c

index f164818ec477a5dfbf694231d400ed0b6c4e3d03..077d006b1fbf50f9488203969d0fab5c8a9498b5 100644 (file)
@@ -145,7 +145,7 @@ static void arcpgu_debugfs_init(struct drm_minor *minor)
 }
 #endif
 
-static struct drm_driver arcpgu_drm_driver = {
+static const struct drm_driver arcpgu_drm_driver = {
        .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC,
        .name = "arcpgu",
        .desc = "ARC PGU Controller",
index a31a840ce63491078a4ebf888e327ff32810ed4a..3c49668ec946dc6921939ee9208244a452191ab7 100644 (file)
@@ -400,7 +400,7 @@ static void kmb_irq_reset(struct drm_device *drm)
 
 DEFINE_DRM_GEM_CMA_FOPS(fops);
 
-static struct drm_driver kmb_driver = {
+static const struct drm_driver kmb_driver = {
        .driver_features = DRIVER_GEM |
            DRIVER_MODESET | DRIVER_ATOMIC,
        .irq_handler = kmb_isr,
index ab699bf0ac5c0f1b5d967b8577a5dcdb693dc3e2..58c185c299f411dfcd514a4b8726a700decfc761 100644 (file)
@@ -56,7 +56,7 @@ static const struct file_operations tdfx_driver_fops = {
        .llseek = noop_llseek,
 };
 
-static struct drm_driver driver = {
+static const struct drm_driver driver = {
        .driver_features = DRIVER_LEGACY,
        .fops = &tdfx_driver_fops,
        .name = DRIVER_NAME,