Commit 14aed8ea authored by Pin-yen Lin's avatar Pin-yen Lin Committed by Douglas Anderson

drm/bridge: ps8640: Return NULL immediately when EDID read fail

drm_edid_read returns NULL on error, so feeding it directly into
drm_edid_duplicate may lead to NULL pointer dereference. Add a check to
guard this.

Fixes: 6a17b4d1 ("drm/bridge: ps8640: Add a cache for EDID")
Signed-off-by: default avatarPin-yen Lin <treapking@chromium.org>
Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230324035909.1727356-1-treapking@chromium.org
parent 6a17b4d1
......@@ -543,6 +543,7 @@ static struct edid *ps8640_bridge_get_edid(struct drm_bridge *bridge,
struct drm_connector *connector)
{
struct ps8640 *ps_bridge = bridge_to_ps8640(bridge);
struct device *dev = &ps_bridge->page[PAGE0_DP_CNTL]->dev;
bool poweroff = !ps_bridge->pre_enabled;
if (!ps_bridge->edid) {
......@@ -574,6 +575,11 @@ static struct edid *ps8640_bridge_get_edid(struct drm_bridge *bridge,
connector->state->state);
}
if (!ps_bridge->edid) {
dev_err(dev, "Failed to get EDID\n");
return NULL;
}
return drm_edid_duplicate(ps_bridge->edid);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment