[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251227121946.67935-1-alperyasinak1@gmail.com>
Date: Sat, 27 Dec 2025 15:19:44 +0300
From: Alper Ak <alperyasinak1@...il.com>
To: mchehab@...nel.org,
hverkuil+cisco@...nel.org
Cc: Alper Ak <alperyasinak1@...il.com>,
Laurent Pinchart <laurent.pinchart+renesas@...asonboard.com>,
Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>,
Tommaso Merciai <tommaso.merciai.xr@...renesas.com>,
Daniel Scally <dan.scally+renesas@...asonboard.com>,
Biju Das <biju.das.jz@...renesas.com>,
Jacopo Mondi <jacopo.mondi@...asonboard.com>,
linux-media@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] media: renesas: rzg2l-cru: Fix possible ERR_PTR dereference in rzg2l_cru_get_virtual_channel()
media_pad_remote_pad_unique() can return ERR_PTR(-ENOTUNIQ) or
ERR_PTR(-ENOLINK) on error situation.
The current code dereferences remote_pad without checking for
these error cases, which could lead to invalid memory access.
Add IS_ERR() check before dereferencing the pointer.
Fixes: d7d72dae81d5 ("media: rzg2l-cru: Retrieve virtual channel information")
Signed-off-by: Alper Ak <alperyasinak1@...il.com>
---
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index 162e2ace6931..bf7d96841c78 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -411,6 +411,9 @@ static int rzg2l_cru_get_virtual_channel(struct rzg2l_cru_dev *cru)
int ret;
remote_pad = media_pad_remote_pad_unique(&cru->ip.pads[RZG2L_CRU_IP_SINK]);
+ if (IS_ERR(remote_pad))
+ return PTR_ERR(remote_pad);
+
ret = v4l2_subdev_call(cru->ip.remote, pad, get_frame_desc, remote_pad->index, &fd);
if (ret < 0 && ret != -ENOIOCTLCMD) {
dev_err(cru->dev, "get_frame_desc failed on IP remote subdev\n");
--
2.43.0
Powered by blists - more mailing lists