* [PATCH] media: mali-c55: Fix possible ERR_PTR dereference in mali_c55_isp_enable_streams()
@ 2025-12-27 11:51 Alper Ak
2026-01-08 14:07 ` Jacopo Mondi
0 siblings, 1 reply; 2+ messages in thread
From: Alper Ak @ 2025-12-27 11:51 UTC (permalink / raw)
To: dan.scally, jacopo.mondi
Cc: Alper Ak, Mauro Carvalho Chehab, Nayden Kanchev, Hans Verkuil,
linux-media, linux-kernel
media_pad_remote_pad_unique() can return ERR_PTR(-ENOTUNIQ) or
ERR_PTR(-ENOLINK) on error situation.
The current code dereferences isp->remote_src without checking
for these error cases, which could lead to invalid memory access.
Add IS_ERR() check before dereferencing the pointer.
Fixes: d5f281f3dd29 ("media: mali-c55: Add Mali-C55 ISP driver")
Signed-off-by: Alper Ak <alperyasinak1@gmail.com>
---
drivers/media/platform/arm/mali-c55/mali-c55-isp.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-isp.c b/drivers/media/platform/arm/mali-c55/mali-c55-isp.c
index 497f25fbdd13..ca1f0bde6f13 100644
--- a/drivers/media/platform/arm/mali-c55/mali-c55-isp.c
+++ b/drivers/media/platform/arm/mali-c55/mali-c55-isp.c
@@ -359,7 +359,11 @@ static int mali_c55_isp_enable_streams(struct v4l2_subdev *sd,
*/
sink_pad = &isp->pads[MALI_C55_ISP_PAD_SINK_VIDEO];
+
isp->remote_src = media_pad_remote_pad_unique(sink_pad);
+ if (IS_ERR(isp->remote_src))
+ return PTR_ERR(isp->remote_src);
+
src_sd = media_entity_to_v4l2_subdev(isp->remote_src->entity);
isp->frame_sequence = 0;
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] media: mali-c55: Fix possible ERR_PTR dereference in mali_c55_isp_enable_streams()
2025-12-27 11:51 [PATCH] media: mali-c55: Fix possible ERR_PTR dereference in mali_c55_isp_enable_streams() Alper Ak
@ 2026-01-08 14:07 ` Jacopo Mondi
0 siblings, 0 replies; 2+ messages in thread
From: Jacopo Mondi @ 2026-01-08 14:07 UTC (permalink / raw)
To: Alper Ak
Cc: dan.scally, jacopo.mondi, Mauro Carvalho Chehab, Nayden Kanchev,
Hans Verkuil, linux-media, linux-kernel
Hello Alper
On Sat, Dec 27, 2025 at 02:51:52PM +0300, Alper Ak wrote:
> media_pad_remote_pad_unique() can return ERR_PTR(-ENOTUNIQ) or
> ERR_PTR(-ENOLINK) on error situation.
>
> The current code dereferences isp->remote_src without checking
> for these error cases, which could lead to invalid memory access.
>
> Add IS_ERR() check before dereferencing the pointer.
>
> Fixes: d5f281f3dd29 ("media: mali-c55: Add Mali-C55 ISP driver")
> Signed-off-by: Alper Ak <alperyasinak1@gmail.com>
> ---
> drivers/media/platform/arm/mali-c55/mali-c55-isp.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-isp.c b/drivers/media/platform/arm/mali-c55/mali-c55-isp.c
> index 497f25fbdd13..ca1f0bde6f13 100644
> --- a/drivers/media/platform/arm/mali-c55/mali-c55-isp.c
> +++ b/drivers/media/platform/arm/mali-c55/mali-c55-isp.c
> @@ -359,7 +359,11 @@ static int mali_c55_isp_enable_streams(struct v4l2_subdev *sd,
> */
>
> sink_pad = &isp->pads[MALI_C55_ISP_PAD_SINK_VIDEO];
> +
> isp->remote_src = media_pad_remote_pad_unique(sink_pad);
> + if (IS_ERR(isp->remote_src))
> + return PTR_ERR(isp->remote_src);
> +
To be honest I'm not sure if this can happen.
-ENOTUNIQ shouldn't be possible as we create a link for the single
subev connected to port 0
-ENOLINK shouldn't be possible as well, as if the remote subdev
doesn't bind we won't have a media graph at all
Being defensive it's always wise, but sometimes being too defensive
might result in the reader asking what the code is protecting against
if an error condition is impossible to reach.
Is there a case which I have missed which can lead to an error
condition ?
Thanks
j
> src_sd = media_entity_to_v4l2_subdev(isp->remote_src->entity);
>
> isp->frame_sequence = 0;
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-08 14:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-27 11:51 [PATCH] media: mali-c55: Fix possible ERR_PTR dereference in mali_c55_isp_enable_streams() Alper Ak
2026-01-08 14:07 ` Jacopo Mondi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox