mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/connector: only call HDMI audio helper plugged cb if non-null
@ 2025-05-27 17:57 Nicolas Frattaroli
  2025-05-27 17:59 ` Dmitry Baryshkov
  2025-05-27 20:10 ` Dmitry Baryshkov
  0 siblings, 2 replies; 3+ messages in thread
From: Nicolas Frattaroli @ 2025-05-27 17:57 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, Dmitry Baryshkov
  Cc: kernel, dri-devel, linux-kernel, Nicolas Frattaroli

On driver remove, sound/soc/codecs/hdmi-codec.c calls the plugged_cb
with NULL as the callback function and codec_dev, as seen in its
hdmi_remove function.

The HDMI audio helper then happily tries calling said null function
pointer, and produces an Oops as a result.

Fix this by only executing the callback if fn is non-null. This means
the .plugged_cb and .plugged_cb_dev members still get appropriately
cleared.

Fixes: baf616647fe6 ("drm/connector: implement generic HDMI audio helpers")
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
 drivers/gpu/drm/display/drm_hdmi_audio_helper.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/display/drm_hdmi_audio_helper.c b/drivers/gpu/drm/display/drm_hdmi_audio_helper.c
index 05afc9f0bdd6b6f00d74223a9d8875e6d16aea5f..ae8a0cf595fc6fb11eecd820c7e8c5b75a746e18 100644
--- a/drivers/gpu/drm/display/drm_hdmi_audio_helper.c
+++ b/drivers/gpu/drm/display/drm_hdmi_audio_helper.c
@@ -103,7 +103,8 @@ static int drm_connector_hdmi_audio_hook_plugged_cb(struct device *dev,
 	connector->hdmi_audio.plugged_cb = fn;
 	connector->hdmi_audio.plugged_cb_dev = codec_dev;
 
-	fn(codec_dev, connector->hdmi_audio.last_state);
+	if (fn)
+		fn(codec_dev, connector->hdmi_audio.last_state);
 
 	mutex_unlock(&connector->hdmi_audio.lock);
 

---
base-commit: 502d44c1a440c5f428f50f02e58cd5633454ea8d
change-id: 20250527-hdmi-audio-helper-remove-fix-43b2cd0e648a

Best regards,
-- 
Nicolas Frattaroli <nicolas.frattaroli@collabora.com>


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

* Re: [PATCH] drm/connector: only call HDMI audio helper plugged cb if non-null
  2025-05-27 17:57 [PATCH] drm/connector: only call HDMI audio helper plugged cb if non-null Nicolas Frattaroli
@ 2025-05-27 17:59 ` Dmitry Baryshkov
  2025-05-27 20:10 ` Dmitry Baryshkov
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Baryshkov @ 2025-05-27 17:59 UTC (permalink / raw)
  To: Nicolas Frattaroli, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Dmitry Baryshkov
  Cc: kernel, dri-devel, linux-kernel

On 27/05/2025 20:57, Nicolas Frattaroli wrote:
> On driver remove, sound/soc/codecs/hdmi-codec.c calls the plugged_cb
> with NULL as the callback function and codec_dev, as seen in its
> hdmi_remove function.
> 
> The HDMI audio helper then happily tries calling said null function
> pointer, and produces an Oops as a result.
> 
> Fix this by only executing the callback if fn is non-null. This means
> the .plugged_cb and .plugged_cb_dev members still get appropriately
> cleared.
> 
> Fixes: baf616647fe6 ("drm/connector: implement generic HDMI audio helpers")
> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
> ---
>   drivers/gpu/drm/display/drm_hdmi_audio_helper.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>

-- 
With best wishes
Dmitry

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

* Re: [PATCH] drm/connector: only call HDMI audio helper plugged cb if non-null
  2025-05-27 17:57 [PATCH] drm/connector: only call HDMI audio helper plugged cb if non-null Nicolas Frattaroli
  2025-05-27 17:59 ` Dmitry Baryshkov
@ 2025-05-27 20:10 ` Dmitry Baryshkov
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Baryshkov @ 2025-05-27 20:10 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, Dmitry Baryshkov,
	Nicolas Frattaroli
  Cc: kernel, dri-devel, linux-kernel

On Tue, 27 May 2025 19:57:08 +0200, Nicolas Frattaroli wrote:
> On driver remove, sound/soc/codecs/hdmi-codec.c calls the plugged_cb
> with NULL as the callback function and codec_dev, as seen in its
> hdmi_remove function.
> 
> The HDMI audio helper then happily tries calling said null function
> pointer, and produces an Oops as a result.
> 
> [...]

Applied to drm-misc-next-fixes, thanks!

[1/1] drm/connector: only call HDMI audio helper plugged cb if non-null
      commit: be9b3f9a54101c19226c25ba7163d291183777a0

Best regards,
-- 
With best wishes
Dmitry



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

end of thread, other threads:[~2025-05-27 20:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-27 17:57 [PATCH] drm/connector: only call HDMI audio helper plugged cb if non-null Nicolas Frattaroli
2025-05-27 17:59 ` Dmitry Baryshkov
2025-05-27 20:10 ` Dmitry Baryshkov

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®