[PATCH v4 02/18] media: verisilicon: Check the match data in hantro_probe()
From: Arun Iyengar via B4 Relay
Date: Sun Dec 06 2026 - 00:57:55 EST
From: Arun Iyengar <aiyengar1990@xxxxxxxxx>
A device bound through driver_override may have no OF match, and
hantro_probe() then dereferences a NULL match. Use
device_get_match_data() and fail with -ENODEV without match data.
Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver")
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@xxxxxxxxxxxxx>
Signed-off-by: Arun Iyengar <aiyengar1990@xxxxxxxxx>
---
drivers/media/platform/verisilicon/hantro_drv.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 5c962847fdf5..da9813c60cf7 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -17,6 +17,7 @@
#include <linux/platform_device.h>
#include <linux/pm.h>
#include <linux/pm_runtime.h>
+#include <linux/property.h>
#include <linux/slab.h>
#include <linux/videodev2.h>
#include <linux/workqueue.h>
@@ -1099,7 +1100,6 @@ static struct v4l2_m2m_dev *hantro_get_v4l2_m2m_dev(struct hantro_dev *vpu)
static int hantro_probe(struct platform_device *pdev)
{
- const struct of_device_id *match;
struct hantro_dev *vpu;
int i, ret;
@@ -1112,8 +1112,9 @@ static int hantro_probe(struct platform_device *pdev)
mutex_init(&vpu->vpu_mutex);
spin_lock_init(&vpu->irqlock);
- match = of_match_node(of_hantro_match, pdev->dev.of_node);
- vpu->variant = match->data;
+ vpu->variant = device_get_match_data(&pdev->dev);
+ if (!vpu->variant)
+ return -ENODEV;
ret = hantro_disable_multicore(vpu);
if (ret)
--
2.55.0