summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/bridge
diff options
context:
space:
mode:
authorJai Luthra <j-luthra@ti.com>2023-09-01 12:31:23 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-11-20 13:59:09 +0300
commit1374561a7cbc9a000b77bb0473bb2c19daf18d86 (patch)
tree135e9921c199fd8db9bf95a4709e7d3f8422580d /drivers/gpu/drm/bridge
parent42ae6a3c36be424b570c7a03e69d0bd6a813e960 (diff)
downloadlinux-1374561a7cbc9a000b77bb0473bb2c19daf18d86.tar.xz
drm: bridge: it66121: Fix invalid connector dereference
[ Upstream commit d0375f6858c4ff7244b62b02eb5e93428e1916cd ] Fix the NULL pointer dereference when no monitor is connected, and the sound card is opened from userspace. Instead return an empty buffer (of zeroes) as the EDID information to the sound framework if there is no connector attached. Fixes: e0fd83dbe924 ("drm: bridge: it66121: Add audio support") Reported-by: Nishanth Menon <nm@ti.com> Closes: https://lore.kernel.org/all/20230825105849.crhon42qndxqif4i@gondola/ Reviewed-by: Helen Koike <helen.koike@collabora.com> Signed-off-by: Jai Luthra <j-luthra@ti.com> Tested-by: Nishanth Menon <nm@ti.com> Reviewed-by: Aradhya Bhatia <a-bhatia1@ti.com> Signed-off-by: Robert Foss <rfoss@kernel.org> Link: https://patchwork.freedesktop.org/patch/msgid/20230901-it66121_edid-v2-1-aa59605336b9@ti.com Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/gpu/drm/bridge')
-rw-r--r--drivers/gpu/drm/bridge/ite-it66121.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/ite-it66121.c
index 466641c77fe9..fc7f5ec5fb38 100644
--- a/drivers/gpu/drm/bridge/ite-it66121.c
+++ b/drivers/gpu/drm/bridge/ite-it66121.c
@@ -1447,10 +1447,14 @@ static int it66121_audio_get_eld(struct device *dev, void *data,
struct it66121_ctx *ctx = dev_get_drvdata(dev);
mutex_lock(&ctx->lock);
-
- memcpy(buf, ctx->connector->eld,
- min(sizeof(ctx->connector->eld), len));
-
+ if (!ctx->connector) {
+ /* Pass en empty ELD if connector not available */
+ dev_dbg(dev, "No connector present, passing empty EDID data");
+ memset(buf, 0, len);
+ } else {
+ memcpy(buf, ctx->connector->eld,
+ min(sizeof(ctx->connector->eld), len));
+ }
mutex_unlock(&ctx->lock);
return 0;