drm/i915/dsi: defend gpio table against out of bounds access
authorJani Nikula <jani.nikula@intel.com>
Thu, 4 Feb 2016 10:50:49 +0000 (12:50 +0200)
committerJani Nikula <jani.nikula@intel.com>
Thu, 4 Feb 2016 16:30:25 +0000 (18:30 +0200)
Do not blindly trust the VBT data used for indexing.

Cc: stable@vger.kernel.org
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/cc32d40c2b47f2d2151811855ac2c3dabab1d57d.1454582914.git.jani.nikula@intel.com
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c

index 1d43e6f37fc1c720e91d19e34401306f31508c88..4775aa5462e86d022883bb1e4776d51fda796743 100644 (file)
@@ -209,6 +209,11 @@ static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
        /* pull up/down */
        action = *data++;
 
+       if (gpio >= ARRAY_SIZE(gtable)) {
+               DRM_DEBUG_KMS("unknown gpio %u\n", gpio);
+               goto out;
+       }
+
        function = gtable[gpio].function_reg;
        pad = gtable[gpio].pad_reg;
 
@@ -226,6 +231,7 @@ static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
        vlv_gpio_nc_write(dev_priv, pad, val);
        mutex_unlock(&dev_priv->sb_lock);
 
+out:
        return data;
 }