drm: remove the raw_edid field from struct drm_display_info
authorJani Nikula <jani.nikula@intel.com>
Wed, 15 Aug 2012 09:32:39 +0000 (09:32 +0000)
committerDave Airlie <airlied@redhat.com>
Thu, 23 Aug 2012 23:37:36 +0000 (09:37 +1000)
Neither the drm core nor any of the drivers really need the raw_edid field
of struct drm_display_info for anything. Instead of being useful, it
creates confusion about who is responsible for freeing the memory it points
to and setting the field to NULL afterwards, leading to memory leaks and
dangling pointers.

Remove the raw_edid field, and fix drivers as necessary.

Reported-by: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
15 files changed:
drivers/gpu/drm/drm_edid.c
drivers/gpu/drm/drm_edid_load.c
drivers/gpu/drm/exynos/exynos_drm_connector.c
drivers/gpu/drm/exynos/exynos_drm_vidi.c
drivers/gpu/drm/gma500/cdv_intel_hdmi.c
drivers/gpu/drm/gma500/oaktrail_hdmi.c
drivers/gpu/drm/gma500/psb_intel_sdvo.c
drivers/gpu/drm/i915/intel_dp.c
drivers/gpu/drm/i915/intel_hdmi.c
drivers/gpu/drm/i915/intel_modes.c
drivers/gpu/drm/i915/intel_sdvo.c
drivers/gpu/drm/mgag200/mgag200_mode.c
drivers/gpu/drm/udl/udl_connector.c
drivers/staging/omapdrm/omap_connector.c
include/drm/drm_crtc.h

index a8743c399e83234c976ebdb4b471542a0645c42d..bcc472572cd09741e38683f4a7d9c62cec5f1c3e 100644 (file)
@@ -399,10 +399,7 @@ struct edid *drm_get_edid(struct drm_connector *connector,
        if (drm_probe_ddc(adapter))
                edid = (struct edid *)drm_do_get_edid(connector, adapter);
 
-       connector->display_info.raw_edid = (char *)edid;
-
        return edid;
-
 }
 EXPORT_SYMBOL(drm_get_edid);
 
index 0303935d10e2ca45165509a7e9e8165962c99774..186832e1874ed071f575c19c0874ae50d2d3e760 100644 (file)
@@ -114,8 +114,8 @@ static u8 generic_edid[GENERIC_EDIDS][128] = {
        },
 };
 
-static int edid_load(struct drm_connector *connector, char *name,
-                    char *connector_name)
+static u8 *edid_load(struct drm_connector *connector, char *name,
+                       char *connector_name)
 {
        const struct firmware *fw;
        struct platform_device *pdev;
@@ -205,7 +205,6 @@ static int edid_load(struct drm_connector *connector, char *name,
                edid = new_edid;
        }
 
-       connector->display_info.raw_edid = edid;
        DRM_INFO("Got %s EDID base block and %d extension%s from "
            "\"%s\" for connector \"%s\"\n", builtin ? "built-in" :
            "external", valid_extensions, valid_extensions == 1 ? "" : "s",
@@ -215,7 +214,10 @@ relfw_out:
        release_firmware(fw);
 
 out:
-       return err;
+       if (err)
+               return ERR_PTR(err);
+
+       return edid;
 }
 
 int drm_load_edid_firmware(struct drm_connector *connector)
@@ -223,6 +225,7 @@ int drm_load_edid_firmware(struct drm_connector *connector)
        char *connector_name = drm_get_connector_name(connector);
        char *edidname = edid_firmware, *last, *colon;
        int ret;
+       struct edid *edid;
 
        if (*edidname == '\0')
                return 0;
@@ -240,13 +243,13 @@ int drm_load_edid_firmware(struct drm_connector *connector)
        if (*last == '\n')
                *last = '\0';
 
-       ret = edid_load(connector, edidname, connector_name);
-       if (ret)
+       edid = (struct edid *) edid_load(connector, edidname, connector_name);
+       if (IS_ERR_OR_NULL(edid))
                return 0;
 
-       drm_mode_connector_update_edid_property(connector,
-           (struct edid *) connector->display_info.raw_edid);
+       drm_mode_connector_update_edid_property(connector, edid);
+       ret = drm_add_edid_modes(connector, edid);
+       kfree(edid);
 
-       return drm_add_edid_modes(connector, (struct edid *)
-           connector->display_info.raw_edid);
+       return ret;
 }
index d9568198c3008b1518096c92ee5ac54f77a70676..9dce3b9c38964aa16942b4a1cf264c1d58312399 100644 (file)
@@ -147,9 +147,7 @@ static int exynos_drm_connector_get_modes(struct drm_connector *connector)
 
                drm_mode_connector_update_edid_property(connector, edid);
                count = drm_add_edid_modes(connector, edid);
-
-               kfree(connector->display_info.raw_edid);
-               connector->display_info.raw_edid = edid;
+               kfree(edid);
        } else {
                struct drm_display_mode *mode = drm_mode_create(connector->dev);
                struct exynos_drm_panel_info *panel;
index bb1550c4dd57db37554954537ef19c61d4e513ce..92395258d641667d91a8d1e9ee7e644ace25dee9 100644 (file)
@@ -102,7 +102,6 @@ static int vidi_get_edid(struct device *dev, struct drm_connector *connector,
                                u8 *edid, int len)
 {
        struct vidi_context *ctx = get_vidi_context(dev);
-       struct edid *raw_edid;
 
        DRM_DEBUG_KMS("%s\n", __FILE__);
 
@@ -115,18 +114,6 @@ static int vidi_get_edid(struct device *dev, struct drm_connector *connector,
                return -EFAULT;
        }
 
-       raw_edid = kzalloc(len, GFP_KERNEL);
-       if (!raw_edid) {
-               DRM_DEBUG_KMS("failed to allocate raw_edid.\n");
-               return -ENOMEM;
-       }
-
-       memcpy(raw_edid, ctx->raw_edid, min((1 + ctx->raw_edid->extensions)
-                                               * EDID_LENGTH, len));
-
-       /* attach the edid data to connector. */
-       connector->display_info.raw_edid = (char *)raw_edid;
-
        memcpy(edid, ctx->raw_edid, min((1 + ctx->raw_edid->extensions)
                                        * EDID_LENGTH, len));
 
index 0c90f0316db1af67634a85b0e4c3f2bb0caa7245..b1b77bb92a858040f890bad041838c3fe2d9ba1e 100644 (file)
@@ -157,8 +157,6 @@ static enum drm_connector_status cdv_hdmi_detect(
                        hdmi_priv->has_hdmi_audio =
                                                drm_detect_monitor_audio(edid);
                }
-
-               psb_intel_connector->base.display_info.raw_edid = NULL;
                kfree(edid);
        }
        return status;
index 2eb3dc4e9c9b03186c2734a5818aacec70892f47..69e51e903f3585f3600e46c6f3baee6a3fed1ab0 100644 (file)
@@ -252,7 +252,6 @@ static int oaktrail_hdmi_get_modes(struct drm_connector *connector)
        if (edid) {
                drm_mode_connector_update_edid_property(connector, edid);
                ret = drm_add_edid_modes(connector, edid);
-               connector->display_info.raw_edid = NULL;
        }
 
        /*
index 0466c7b985f849bba2b7adf6faa7d022e4a19f88..a453d94f115c4e96c58f0e802b1d7131be1744ee 100644 (file)
@@ -1343,7 +1343,6 @@ psb_intel_sdvo_hdmi_sink_detect(struct drm_connector *connector)
                        }
                } else
                        status = connector_status_disconnected;
-               connector->display_info.raw_edid = NULL;
                kfree(edid);
        }
 
@@ -1404,7 +1403,6 @@ psb_intel_sdvo_detect(struct drm_connector *connector, bool force)
                                ret = connector_status_disconnected;
                        else
                                ret = connector_status_connected;
-                       connector->display_info.raw_edid = NULL;
                        kfree(edid);
                } else
                        ret = connector_status_connected;
@@ -1453,7 +1451,6 @@ static void psb_intel_sdvo_get_ddc_modes(struct drm_connector *connector)
                        drm_add_edid_modes(connector, edid);
                }
 
-               connector->display_info.raw_edid = NULL;
                kfree(edid);
        }
 }
index 977d9d216c73b24284507c557626d7c5c7ecb4e2..d14b1e39244c3c75414a57203f8c55b7704710ed 100644 (file)
@@ -2145,7 +2145,6 @@ intel_dp_get_edid_modes(struct drm_connector *connector, struct i2c_adapter *ada
                ret = drm_add_edid_modes(connector, intel_dp->edid);
                drm_edid_to_eld(connector,
                                intel_dp->edid);
-               connector->display_info.raw_edid = NULL;
                return intel_dp->edid_mode_count;
        }
 
@@ -2191,7 +2190,6 @@ intel_dp_detect(struct drm_connector *connector, bool force)
                edid = intel_dp_get_edid(connector, &intel_dp->adapter);
                if (edid) {
                        intel_dp->has_audio = drm_detect_monitor_audio(edid);
-                       connector->display_info.raw_edid = NULL;
                        kfree(edid);
                }
        }
@@ -2256,8 +2254,6 @@ intel_dp_detect_audio(struct drm_connector *connector)
        edid = intel_dp_get_edid(connector, &intel_dp->adapter);
        if (edid) {
                has_audio = drm_detect_monitor_audio(edid);
-
-               connector->display_info.raw_edid = NULL;
                kfree(edid);
        }
 
index e4c37bb572e87da0e6492f9b15f2e4c749d9218c..35a6ee7a8ccaff1a6a024cc5f25529e1313d42b3 100644 (file)
@@ -737,7 +737,6 @@ intel_hdmi_detect(struct drm_connector *connector, bool force)
                                                drm_detect_hdmi_monitor(edid);
                        intel_hdmi->has_audio = drm_detect_monitor_audio(edid);
                }
-               connector->display_info.raw_edid = NULL;
                kfree(edid);
        }
 
@@ -778,8 +777,6 @@ intel_hdmi_detect_audio(struct drm_connector *connector)
        if (edid) {
                if (edid->input & DRM_EDID_INPUT_DIGITAL)
                        has_audio = drm_detect_monitor_audio(edid);
-
-               connector->display_info.raw_edid = NULL;
                kfree(edid);
        }
 
index 45848b9b670b0538625a18fca7427fd98a3155ae..7a5238fc1a02510c37211b48db2bcdcc33d6ef58 100644 (file)
@@ -50,7 +50,6 @@ int intel_ddc_get_modes(struct drm_connector *connector,
                drm_mode_connector_update_edid_property(connector, edid);
                ret = drm_add_edid_modes(connector, edid);
                drm_edid_to_eld(connector, edid);
-               connector->display_info.raw_edid = NULL;
                kfree(edid);
        }
 
index 5fb425bf4d03e294b9f09f989208091c2fe09f9f..434b1d1d3c8463f958fba9622910a09f88bf9fec 100644 (file)
@@ -1345,7 +1345,6 @@ intel_sdvo_tmds_sink_detect(struct drm_connector *connector)
                        }
                } else
                        status = connector_status_disconnected;
-               connector->display_info.raw_edid = NULL;
                kfree(edid);
        }
 
@@ -1419,7 +1418,6 @@ intel_sdvo_detect(struct drm_connector *connector, bool force)
                        else
                                ret = connector_status_disconnected;
 
-                       connector->display_info.raw_edid = NULL;
                        kfree(edid);
                } else
                        ret = connector_status_connected;
@@ -1465,7 +1463,6 @@ static void intel_sdvo_get_ddc_modes(struct drm_connector *connector)
                        drm_add_edid_modes(connector, edid);
                }
 
-               connector->display_info.raw_edid = NULL;
                kfree(edid);
        }
 }
index b69642d5d850581694fe8741056a5d0529f4eeed..c7420e83c0b98ee98c2e4a86ed9d362f0d224291 100644 (file)
@@ -1399,7 +1399,6 @@ static int mga_vga_get_modes(struct drm_connector *connector)
        if (edid) {
                drm_mode_connector_update_edid_property(connector, edid);
                ret = drm_add_edid_modes(connector, edid);
-               connector->display_info.raw_edid = NULL;
                kfree(edid);
        }
        return ret;
index ba055e9ca0077875a3a49d3533d729a95ccf98fd..2d98ff92f3baaa33171ae1506edcca8992281f8b 100644 (file)
@@ -57,11 +57,8 @@ static int udl_get_modes(struct drm_connector *connector)
 
        edid = (struct edid *)udl_get_edid(udl);
 
-       connector->display_info.raw_edid = (char *)edid;
-
        drm_mode_connector_update_edid_property(connector, edid);
        ret = drm_add_edid_modes(connector, edid);
-       connector->display_info.raw_edid = NULL;
        kfree(edid);
        return ret;
 }
index 5e2856c0e0bbf3ead714ca105d06e54e1dff1545..9c2287b71d29dbea4da97af0a0518e37f6086083 100644 (file)
@@ -177,14 +177,11 @@ static int omap_connector_get_modes(struct drm_connector *connector)
                        drm_mode_connector_update_edid_property(
                                        connector, edid);
                        n = drm_add_edid_modes(connector, edid);
-                       kfree(connector->display_info.raw_edid);
-                       connector->display_info.raw_edid = edid;
                } else {
                        drm_mode_connector_update_edid_property(
                                        connector, NULL);
-                       connector->display_info.raw_edid = NULL;
-                       kfree(edid);
                }
+               kfree(edid);
        } else {
                struct drm_display_mode *mode = drm_mode_create(dev);
                struct omap_video_timings timings;
index a1a0386e0160d9278f6b74e213f26915a87551af..0522044b7498d4cdadd870fe23877a0e6e149b2e 100644 (file)
@@ -216,8 +216,6 @@ struct drm_display_info {
        u32 color_formats;
 
        u8 cea_rev;
-
-       char *raw_edid; /* if any */
 };
 
 struct drm_framebuffer_funcs {