[Intel-gfx] [PATCH 05/29] drm/i915: prevent NULL pointer exception when using gmbus
Eugeni Dodonov
eugeni.dodonov at intel.com
Fri Apr 13 22:08:41 CEST 2012
Prevent a NULL pointer exception when we are trying to retrieve EDID data
from non-existent adapter.
Signed-off-by: Eugeni Dodonov <eugeni.dodonov at intel.com>
---
drivers/gpu/drm/i915/intel_hdmi.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index f6a9b83..700bd0b 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -389,14 +389,16 @@ intel_hdmi_detect(struct drm_connector *connector, bool force)
{
struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
struct drm_i915_private *dev_priv = connector->dev->dev_private;
- struct edid *edid;
+ struct edid *edid = NULL;
enum drm_connector_status status = connector_status_disconnected;
+ struct i2c_adapter *adapter;
intel_hdmi->has_hdmi_sink = false;
intel_hdmi->has_audio = false;
- edid = drm_get_edid(connector,
- intel_gmbus_get_adapter(dev_priv,
- intel_hdmi->ddc_bus));
+
+ adapter = intel_gmbus_get_adapter(dev_priv, intel_hdmi->ddc_bus);
+ if (adapter)
+ edid = drm_get_edid(connector, adapter);
if (edid) {
if (edid->input & DRM_EDID_INPUT_DIGITAL) {
@@ -423,14 +425,17 @@ static int intel_hdmi_get_modes(struct drm_connector *connector)
{
struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
struct drm_i915_private *dev_priv = connector->dev->dev_private;
+ struct i2c_adapter *adapter;
/* We should parse the EDID data and find out if it's an HDMI sink so
* we can send audio to it.
*/
- return intel_ddc_get_modes(connector,
- intel_gmbus_get_adapter(dev_priv,
- intel_hdmi->ddc_bus));
+ adapter = intel_gmbus_get_adapter(dev_priv, intel_hdmi->ddc_bus);
+ if (!adapter)
+ return 0;
+
+ return intel_ddc_get_modes(connector, adapter);
}
static bool
@@ -438,12 +443,15 @@ intel_hdmi_detect_audio(struct drm_connector *connector)
{
struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
struct drm_i915_private *dev_priv = connector->dev->dev_private;
- struct edid *edid;
+ struct edid *edid = NULL;
bool has_audio = false;
+ struct i2c_adapter *adapter;
+
+ adapter = intel_gmbus_get_adapter(dev_priv, intel_hdmi->ddc_bus);
+
+ if (adapter)
+ edid = drm_get_edid(connector, adapter);
- edid = drm_get_edid(connector,
- intel_gmbus_get_adapter(dev_priv,
- intel_hdmi->ddc_bus));
if (edid) {
if (edid->input & DRM_EDID_INPUT_DIGITAL)
has_audio = drm_detect_monitor_audio(edid);
--
1.7.10
More information about the Intel-gfx
mailing list