[PATCH 2/5] staging: media: max96712: add NULL check for of_device_get_match_data()
From: Alexandru Hossu
Date: Sun Apr 12 2026 - 16:54:02 EST
max96712_probe() calls of_device_get_match_data() to retrieve chip-specific
data from the device tree match table, but does not check the return value
for NULL before using it.
The pointer is dereferenced later in the same probe call via
max96712_mipi_configure(), which accesses priv->info->dpllfreq. A NULL
return would cause a kernel NULL pointer dereference.
Add a NULL check returning -ENODEV immediately after the call, consistent
with the defensive pattern used in other staging media drivers.
Signed-off-by: Alexandru Hossu <hossu.alexandru@xxxxxxxxx>
---
drivers/staging/media/max96712/max96712.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/staging/media/max96712/max96712.c b/drivers/staging/media/max96712/max96712.c
index 0751b2e04895..8a65c37ac739 100644
--- a/drivers/staging/media/max96712/max96712.c
+++ b/drivers/staging/media/max96712/max96712.c
@@ -416,6 +416,8 @@ static int max96712_probe(struct i2c_client *client)
return -ENOMEM;
priv->info = of_device_get_match_data(&client->dev);
+ if (!priv->info)
+ return -ENODEV;
priv->client = client;
--
2.53.0