[PATCH] drm/i915: Fix missing check for return value of dev_get_platdata()

From: Chenyuan Mi
Date: Wed Jun 14 2023 - 11:56:47 EST


The dev_get_platdata() function may return NULL, which may
cause null pointer deference, and most other callsites of
dev_get_platdata() do Null check. Add Null check for return
value of dev_get_platdata().

Found by our static analysis tool.

Signed-off-by: Chenyuan Mi <cymi20@xxxxxxxxxxxx>
---
drivers/gpu/drm/i915/display/intel_lpe_audio.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/i915/display/intel_lpe_audio.c b/drivers/gpu/drm/i915/display/intel_lpe_audio.c
index 5863763de530..a1655ddbe910 100644
--- a/drivers/gpu/drm/i915/display/intel_lpe_audio.c
+++ b/drivers/gpu/drm/i915/display/intel_lpe_audio.c
@@ -336,6 +336,9 @@ void intel_lpe_audio_notify(struct drm_i915_private *dev_priv,
return;

pdata = dev_get_platdata(&dev_priv->display.audio.lpe.platdev->dev);
+ if (!pdata)
+ return;
+
ppdata = &pdata->port[port - PORT_B];

spin_lock_irqsave(&pdata->lpe_audio_slock, irqflags);
--
2.17.1