Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 451023dc authored by Jani Nikula's avatar Jani Nikula Committed by Dave Airlie
Browse files

drm: remove the raw_edid field from struct drm_display_info



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: default avatarRussell King <linux@arm.linux.org.uk>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Acked-by: default avatarInki Dae <inki.dae@samsung.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 993dcb05
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -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);

+13 −10
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ static u8 generic_edid[GENERIC_EDIDS][128] = {
	},
};

static int edid_load(struct drm_connector *connector, char *name,
static u8 *edid_load(struct drm_connector *connector, char *name,
			char *connector_name)
{
	const struct firmware *fw;
@@ -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 @@ static int edid_load(struct drm_connector *connector, char *name,
	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;
}
+1 −3
Original line number Diff line number Diff line
@@ -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;
+0 −13
Original line number Diff line number Diff line
@@ -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));

+0 −2
Original line number Diff line number Diff line
@@ -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;
Loading