Skip to contentSkip to conversation

FAILED: Patch "media: rockchip: rga: Fix possible ERR_PTR dereference in rga_buf_init()" failed to apply to 6.12-stable tree

PATCH Sasha Levin 1 participant 1 message Mar 1

Subsystems (4)
lore
Share & tools
lore

Sasha Levin

author maintainer
#0 lore raw

The patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

Thanks,
Sasha

------------------ original commit in Linus's tree ------------------

From 81f8e0e6a2e115df9274d0289779f8fca694479c Mon Sep 17 00:00:00 2001
From: Alper Ak <[email protected]>
Date: Sat, 27 Dec 2025 11:40:37 +0300
Subject: [PATCH] media: rockchip: rga: Fix possible ERR_PTR dereference in
rga_buf_init()

rga_get_frame() can return ERR_PTR(-EINVAL) when buffer type is unsupported or invalid. rga_buf_init() does not check the return value and unconditionally dereferences the pointer when accessing f->size.

Add proper ERR_PTR checking and return the error to prevent dereferencing an invalid pointer.

Fixes 6040702ade23 ("media: rockchip: rga: allocate DMA descriptors per buffer")
---
 drivers/media/platform/rockchip/rga/rga-buf.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/media/platform/rockchip/rga/rga-buf.c +3 -0
index 730bdf98565a5..bb575873f2b24 100644
@@ -80,6 +80,9 @@ static int rga_buf_init(struct vb2_buffer *vb)
 	struct rga_frame *f = rga_get_frame(ctx, vb->vb2_queue->type);
 	size_t n_desc = 0;
 
+	if (IS_ERR(f))
+		return PTR_ERR(f);
+
 	n_desc = DIV_ROUND_UP(f->size, PAGE_SIZE);
 
 	rbuf->n_desc = n_desc;
Signature · 1 line
2.51.0