From: Hyeonjun Hong <hyeonjunhong330@gmail.com>
To: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>,
Magnus Damm <magnus.damm@gmail.com>,
linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH 2/2] media: rcar-isp: Fail buffer preparation if the ConfigDMA buffer is full
Date: Thu, 3 Dec 2026 00:17:18 +0900 [thread overview]
Message-ID: <20261202151718.694973-3-hyeonjunhong330@gmail.com> (raw)
In-Reply-To: <20261202151718.694973-1-hyeonjunhong330@gmail.com>
risp_conf_dma_prepare() returns -ENOMEM when the ConfigDMA buffer is
full, but the rppx1 block handlers that call it do not check the result
of the write callback. rppx1_params() then returns 0, the remaining
register writes are dropped without notice and the truncated
configuration is queued.
Record the condition in the write descriptor and fail
risp_io_params_buffer_prepare() if it was hit, instead of adding error
handling to every write in the rppx1 block handlers.
Signed-off-by: Hyeonjun Hong <hyeonjunhong330@gmail.com>
---
drivers/media/platform/renesas/rcar-isp/core-io.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/renesas/rcar-isp/core-io.c b/drivers/media/platform/renesas/rcar-isp/core-io.c
index 5c6018491160..a5f18aeb1f28 100644
--- a/drivers/media/platform/renesas/rcar-isp/core-io.c
+++ b/drivers/media/platform/renesas/rcar-isp/core-io.c
@@ -501,6 +501,7 @@ struct risp_conf_dma_write_desc {
u32 *buf;
u32 base;
unsigned int count;
+ bool overflow;
};
static int risp_conf_dma_prepare(void *priv, u32 offset, u32 value)
@@ -508,8 +509,10 @@ static int risp_conf_dma_prepare(void *priv, u32 offset, u32 value)
struct risp_conf_dma_write_desc *desc = priv;
/* Bounds check, 8 bytes header + 8 bytes = address (4) + value (4). */
- if (8 + (desc->count + 1) * 8 > RISP_IO_PARAMS_BUF_SIZE)
+ if (8 + (desc->count + 1) * 8 > RISP_IO_PARAMS_BUF_SIZE) {
+ desc->overflow = true;
return -ENOMEM;
+ }
(*desc->buf++) = desc->base | offset;
(*desc->buf++) = value;
@@ -534,6 +537,7 @@ static int risp_io_params_buffer_prepare(struct vb2_buffer *vb)
desc.buf = cpu_addr + 2;
desc.base = io->core->rppaddr;
desc.count = 0;
+ desc.overflow = false;
/* Fill params body. */
ret = rppx1_params(io->core->rpp, vb, io->format.fmt.meta.buffersize,
@@ -541,6 +545,10 @@ static int risp_io_params_buffer_prepare(struct vb2_buffer *vb)
if (ret)
return ret;
+ /* The block handlers do not check the result of the write callback. */
+ if (desc.overflow)
+ return -ENOMEM;
+
/* Fill params header. */
cpu_addr[0] = desc.count;
cpu_addr[1] = 0x0;
--
2.34.1
prev parent reply other threads:[~2026-12-02 15:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 15:17 [PATCH 0/2] media: rcar-isp: Fix ConfigDMA buffer overflow Hyeonjun Hong
2026-12-02 15:17 ` [PATCH 1/2] media: rcar-isp: Account for the header in the ConfigDMA bounds check Hyeonjun Hong
2026-12-02 15:17 ` Hyeonjun Hong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202151718.694973-3-hyeonjunhong330@gmail.com \
--to=hyeonjunhong330@gmail.com \
--cc=geert+renesas@glider.be \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=mchehab@kernel.org \
--cc=niklas.soderlund@ragnatech.se \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®