drm/gma500: fix null pointer dereference in cdv_intel_lvds_get_modes
authorMa Ke <make24@iscas.ac.cn>
Tue, 9 Jul 2024 11:33:11 +0000 (19:33 +0800)
committerPatrik Jakobsson <patrik.r.jakobsson@gmail.com>
Tue, 9 Jul 2024 18:02:14 +0000 (20:02 +0200)
In cdv_intel_lvds_get_modes(), the return value of drm_mode_duplicate()
is assigned to mode, which will lead to a NULL pointer dereference on
failure of drm_mode_duplicate(). Add a check to avoid npd.

Cc: stable@vger.kernel.org
Fixes: 6a227d5fd6c4 ("gma500: Add support for Cedarview")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Signed-off-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240709113311.37168-1-make24@iscas.ac.cn
drivers/gpu/drm/gma500/cdv_intel_lvds.c

index f08a6803dc184965aedc2dd8ade8d11c0723fa10..3adc2c9ab72da01e36513028cf582b6e3f41e2d7 100644 (file)
@@ -311,6 +311,9 @@ static int cdv_intel_lvds_get_modes(struct drm_connector *connector)
        if (mode_dev->panel_fixed_mode != NULL) {
                struct drm_display_mode *mode =
                    drm_mode_duplicate(dev, mode_dev->panel_fixed_mode);
+               if (!mode)
+                       return 0;
+
                drm_mode_probed_add(connector, mode);
                return 1;
        }