* [PATCH] media: coda: link to the VDOA to fix use-after-free on unbind
@ 2026-12-02 8:28 Prasanth R
0 siblings, 0 replies; only message in thread
From: Prasanth R @ 2026-12-02 8:28 UTC (permalink / raw)
To: Philipp Zabel, Mauro Carvalho Chehab
Cc: Michael Tretter, linux-media, linux-kernel, Prasanth R
coda keeps a pointer to the VDOA driver data from probe, but nothing
keeps the VDOA bound. After the VDOA is unbound, its devres data is
freed, and the next open of a coda video node uses it. On the i.MX6Q
SABRE-SD:
echo 21e4000.vdoa > /sys/bus/platform/drivers/imx-vdoa/unbind
: < /dev/video10
BUG: KASAN: slab-use-after-free in vdoa_context_create+0x34/0xbc
Read of size 4 at addr c9bd9448
Add a device link from coda to the VDOA, so unbinding the VDOA unbinds
coda first.
Fixes: e7f3c5481035 ("[media] coda: use VDOA for un-tiling custom macroblock format")
Signed-off-by: Prasanth R <prasanth.r@lineo.co.jp>
---
Tested on the i.MX6Q SABRE-SD with KASAN: no crash after the fix,
and coda binds again after the VDOA is bound again.
Suspend to RAM and resume still work.
I used an AI assistant (Claude) to find this and write the change.
drivers/media/platform/chips-media/coda/coda-common.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/chips-media/coda/coda-common.c b/drivers/media/platform/chips-media/coda/coda-common.c
index be37ea568..48c18533e 100644
--- a/drivers/media/platform/chips-media/coda/coda-common.c
+++ b/drivers/media/platform/chips-media/coda/coda-common.c
@@ -396,7 +396,7 @@ const char *coda_product_name(int product)
}
}
-static struct vdoa_data *coda_get_vdoa_data(void)
+static struct vdoa_data *coda_get_vdoa_data(struct device *dev)
{
struct device_node *vdoa_node;
struct platform_device *vdoa_pdev;
@@ -411,8 +411,13 @@ static struct vdoa_data *coda_get_vdoa_data(void)
goto out;
vdoa_data = platform_get_drvdata(vdoa_pdev);
- if (!vdoa_data)
+ if (!vdoa_data) {
vdoa_data = ERR_PTR(-EPROBE_DEFER);
+ } else if (!device_link_add(dev, &vdoa_pdev->dev,
+ DL_FLAG_AUTOREMOVE_CONSUMER)) {
+ dev_warn(dev, "failed to link to VDOA, not using it\n");
+ vdoa_data = NULL;
+ }
put_device(&vdoa_pdev->dev);
out:
@@ -3220,7 +3225,7 @@ static int coda_probe(struct platform_device *pdev)
dev->iram_pool = pool;
/* Get vdoa_data if supported by the platform */
- dev->vdoa = coda_get_vdoa_data();
+ dev->vdoa = coda_get_vdoa_data(&pdev->dev);
if (PTR_ERR(dev->vdoa) == -EPROBE_DEFER)
return -EPROBE_DEFER;
--
2.34.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-02 8:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 8:28 [PATCH] media: coda: link to the VDOA to fix use-after-free on unbind Prasanth R
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.