mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] drm: bridge: it66121: Fix invalid connector dereference
@ 2023-09-01  9:31 Jai Luthra
  2023-09-01 11:31 ` Aradhya Bhatia
  2023-09-05 14:26 ` Robert Foss
  0 siblings, 2 replies; 4+ messages in thread
From: Jai Luthra @ 2023-09-01  9:31 UTC (permalink / raw)
  To: Phong LE, Neil Armstrong, Andrzej Hajda, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec, David Airlie,
	Daniel Vetter, Nicolas Belin, Andy.Hsieh
  Cc: Helen Koike, dri-devel, linux-kernel, linux-arm-kernel,
	Aradhya Bhatia, devarsht, nm, Jai Luthra

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>
---
Changes in v2:
- Return an empty buffer of 0s instead of returning an error
- Lock the mutex before accessing ctx->connector
- Link to v1: https://lore.kernel.org/r/20230825-it66121_edid-v1-1-3ab54923e472@ti.com
---
 drivers/gpu/drm/bridge/ite-it66121.c | 12 ++++++++----
 1 file 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;

---
base-commit: 99d99825fc075fd24b60cc9cf0fb1e20b9c16b0f
change-id: 20230825-it66121_edid-6ee98517808b

Best regards,
-- 
Jai Luthra <j-luthra@ti.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] drm: bridge: it66121: Fix invalid connector dereference
  2023-09-01  9:31 [PATCH v2] drm: bridge: it66121: Fix invalid connector dereference Jai Luthra
@ 2023-09-01 11:31 ` Aradhya Bhatia
  2023-09-01 14:10   ` Nishanth Menon
  2023-09-05 14:26 ` Robert Foss
  1 sibling, 1 reply; 4+ messages in thread
From: Aradhya Bhatia @ 2023-09-01 11:31 UTC (permalink / raw)
  To: Jai Luthra, Phong LE, Neil Armstrong, Andrzej Hajda, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec, David Airlie,
	Daniel Vetter, Nicolas Belin, Andy.Hsieh
  Cc: Helen Koike, dri-devel, linux-kernel, linux-arm-kernel, devarsht, nm



On 01-Sep-23 15:01, Jai Luthra wrote:
> 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>

Reviewed-by: Aradhya Bhatia <a-bhatia1@ti.com>

Regards
Aradhya

> ---
> Changes in v2:
> - Return an empty buffer of 0s instead of returning an error
> - Lock the mutex before accessing ctx->connector
> - Link to v1: https://lore.kernel.org/r/20230825-it66121_edid-v1-1-3ab54923e472@ti.com
> ---
>  drivers/gpu/drm/bridge/ite-it66121.c | 12 ++++++++----
>  1 file 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;
> 
> ---
> base-commit: 99d99825fc075fd24b60cc9cf0fb1e20b9c16b0f
> change-id: 20230825-it66121_edid-6ee98517808b
> 
> Best regards,


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] drm: bridge: it66121: Fix invalid connector dereference
  2023-09-01 11:31 ` Aradhya Bhatia
@ 2023-09-01 14:10   ` Nishanth Menon
  0 siblings, 0 replies; 4+ messages in thread
From: Nishanth Menon @ 2023-09-01 14:10 UTC (permalink / raw)
  To: Aradhya Bhatia
  Cc: Jai Luthra, Phong LE, Neil Armstrong, Andrzej Hajda, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec, David Airlie,
	Daniel Vetter, Nicolas Belin, Andy.Hsieh, Helen Koike, dri-devel,
	linux-kernel, linux-arm-kernel, devarsht

On 17:01-20230901, Aradhya Bhatia wrote:
> On 01-Sep-23 15:01, Jai Luthra wrote:
> > 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>
> 
> Reviewed-by: Aradhya Bhatia <a-bhatia1@ti.com>
> 

Tested-by: Nishanth Menon <nm@ti.com>

Log (beagleplay): https://gist.github.com/nmenon/17fea9316cbcc5ee47597a39fa5e2d6f

Tested on 99d99825fc07 (origin/master, origin/HEAD) Merge tag 'nfs-for-6.6-1' of git://git.linux-nfs.org/projects/anna/linux-nfs

Could we get this merged for rc1 cycle?

-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] drm: bridge: it66121: Fix invalid connector dereference
  2023-09-01  9:31 [PATCH v2] drm: bridge: it66121: Fix invalid connector dereference Jai Luthra
  2023-09-01 11:31 ` Aradhya Bhatia
@ 2023-09-05 14:26 ` Robert Foss
  1 sibling, 0 replies; 4+ messages in thread
From: Robert Foss @ 2023-09-05 14:26 UTC (permalink / raw)
  To: Laurent Pinchart, David Airlie, Jonas Karlman, Jernej Skrabec,
	Nicolas Belin, Daniel Vetter, Jai Luthra, Andy.Hsieh, Phong LE,
	Andrzej Hajda, Neil Armstrong
  Cc: nm, Helen Koike, dri-devel, linux-arm-kernel, linux-kernel,
	devarsht, Aradhya Bhatia

On Fri, 1 Sep 2023 15:01:23 +0530, Jai Luthra wrote:
> 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.
> 
> 
> [...]

Applied, thanks!

[1/1] drm: bridge: it66121: Fix invalid connector dereference
      https://cgit.freedesktop.org/drm/drm-misc/commit/?id=d0375f6858c4



Rob


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-09-05 16:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-01  9:31 [PATCH v2] drm: bridge: it66121: Fix invalid connector dereference Jai Luthra
2023-09-01 11:31 ` Aradhya Bhatia
2023-09-01 14:10   ` Nishanth Menon
2023-09-05 14:26 ` Robert Foss

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®