All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: rzg2l-cru: Fix error pointer dereference
@ 2026-02-17  4:10 Ethan Tidmore
  2026-06-05  7:44 ` Jacopo Mondi
  0 siblings, 1 reply; 2+ messages in thread
From: Ethan Tidmore @ 2026-02-17  4:10 UTC (permalink / raw)
  To: Lad Prabhakar, Mauro Carvalho Chehab
  Cc: Laurent Pinchart, Hans Verkuil, Tommaso Merciai, Daniel Scally,
	Biju Das, Jacopo Mondi, linux-media, linux-kernel, Ethan Tidmore

The function media_pad_remote_pad_unique() can return an error pointer
and is not checked. Add check for error pointer.

Detected by Smatch:
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c:414 rzg2l_cru_get_virtual_channel() error:
'remote_pad' dereferencing possible ERR_PTR()

Fixes: d7d72dae81d5d ("media: rzg2l-cru: Retrieve virtual channel information")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.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.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] media: rzg2l-cru: Fix error pointer dereference
  2026-02-17  4:10 [PATCH] media: rzg2l-cru: Fix error pointer dereference Ethan Tidmore
@ 2026-06-05  7:44 ` Jacopo Mondi
  0 siblings, 0 replies; 2+ messages in thread
From: Jacopo Mondi @ 2026-06-05  7:44 UTC (permalink / raw)
  To: Ethan Tidmore
  Cc: Lad Prabhakar, Mauro Carvalho Chehab, Laurent Pinchart,
	Hans Verkuil, Tommaso Merciai, Daniel Scally, Biju Das,
	Jacopo Mondi, linux-media, linux-kernel

Hi Ethan

On Mon, Feb 16, 2026 at 10:10:55PM -0600, Ethan Tidmore wrote:
> The function media_pad_remote_pad_unique() can return an error pointer
> and is not checked. Add check for error pointer.
>
> Detected by Smatch:
> drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c:414 rzg2l_cru_get_virtual_channel() error:
> 'remote_pad' dereferencing possible ERR_PTR()
>
> Fixes: d7d72dae81d5d ("media: rzg2l-cru: Retrieve virtual channel information")
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>

This really fell into the cracks and you've not been given any
feedback. Sorry about this.

> ---
>  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);
> +

As far as I can tell the link on the cru->ip sink pad is created with
IMMUTABLE flag, so we're sure it always is there.

I don't think the check is required.

Thanks
  j
>  	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.53.0
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-05  7:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-17  4:10 [PATCH] media: rzg2l-cru: Fix error pointer dereference Ethan Tidmore
2026-06-05  7:44 ` Jacopo Mondi

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.