* [PATCH] media: v4l2-subdev: Fix error check in v4l2_subdev_get_frame_desc_passthrough()
@ 2026-03-13 6:39 Chen Ni
2026-03-13 15:11 ` Jacopo Mondi
2026-03-16 7:58 ` Tomi Valkeinen
0 siblings, 2 replies; 3+ messages in thread
From: Chen Ni @ 2026-03-13 6:39 UTC (permalink / raw)
To: linux-media
Cc: mchehab, hverkuil+cisco, laurent.pinchart, sakari.ailus,
jacopo.mondi, tomi.valkeinen+renesas, kees, Chen Ni
Use IS_ERR() and PTR_ERR() to properly handle the error return from
media_pad_remote_pad_unique(), which returns ERR_PTR() on failure but
never NULL. The previous code only checked for NULL, leading to invalid
pointer dereference.
Fixes: a564839e630c ("media: subdev: Add v4l2_subdev_get_frame_desc_passthrough helper")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
drivers/media/v4l2-core/v4l2-subdev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 9efd14d4026f..7cb17e0a5617 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -2585,10 +2585,10 @@ int v4l2_subdev_get_frame_desc_passthrough(struct v4l2_subdev *sd,
if (!have_source_fd) {
remote_source_pad = media_pad_remote_pad_unique(local_sink_pad);
- if (!remote_source_pad) {
+ if (IS_ERR(remote_source_pad)) {
dev_dbg(dev, "Failed to find remote pad for sink pad %u\n",
local_sink_pad->index);
- ret = -EINVAL;
+ ret = PTR_ERR(remote_source_pad);
goto out_unlock;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] media: v4l2-subdev: Fix error check in v4l2_subdev_get_frame_desc_passthrough()
2026-03-13 6:39 [PATCH] media: v4l2-subdev: Fix error check in v4l2_subdev_get_frame_desc_passthrough() Chen Ni
@ 2026-03-13 15:11 ` Jacopo Mondi
2026-03-16 7:58 ` Tomi Valkeinen
1 sibling, 0 replies; 3+ messages in thread
From: Jacopo Mondi @ 2026-03-13 15:11 UTC (permalink / raw)
To: Chen Ni
Cc: linux-media, mchehab, hverkuil+cisco, laurent.pinchart,
sakari.ailus, jacopo.mondi, tomi.valkeinen+renesas, kees
Hello Chen Ni,
On Fri, Mar 13, 2026 at 02:39:46PM +0800, Chen Ni wrote:
> Use IS_ERR() and PTR_ERR() to properly handle the error return from
> media_pad_remote_pad_unique(), which returns ERR_PTR() on failure but
> never NULL. The previous code only checked for NULL, leading to invalid
> pointer dereference.
>
> Fixes: a564839e630c ("media: subdev: Add v4l2_subdev_get_frame_desc_passthrough helper")
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
Seems like a bug indeed, thanks!
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> ---
> drivers/media/v4l2-core/v4l2-subdev.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> index 9efd14d4026f..7cb17e0a5617 100644
> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> @@ -2585,10 +2585,10 @@ int v4l2_subdev_get_frame_desc_passthrough(struct v4l2_subdev *sd,
>
> if (!have_source_fd) {
> remote_source_pad = media_pad_remote_pad_unique(local_sink_pad);
> - if (!remote_source_pad) {
> + if (IS_ERR(remote_source_pad)) {
> dev_dbg(dev, "Failed to find remote pad for sink pad %u\n",
> local_sink_pad->index);
> - ret = -EINVAL;
> + ret = PTR_ERR(remote_source_pad);
> goto out_unlock;
> }
>
> --
> 2.25.1
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] media: v4l2-subdev: Fix error check in v4l2_subdev_get_frame_desc_passthrough()
2026-03-13 6:39 [PATCH] media: v4l2-subdev: Fix error check in v4l2_subdev_get_frame_desc_passthrough() Chen Ni
2026-03-13 15:11 ` Jacopo Mondi
@ 2026-03-16 7:58 ` Tomi Valkeinen
1 sibling, 0 replies; 3+ messages in thread
From: Tomi Valkeinen @ 2026-03-16 7:58 UTC (permalink / raw)
To: Chen Ni, linux-media
Cc: mchehab, hverkuil+cisco, laurent.pinchart, sakari.ailus,
jacopo.mondi, kees
Hi,
On 13/03/2026 08:39, Chen Ni wrote:
> Use IS_ERR() and PTR_ERR() to properly handle the error return from
> media_pad_remote_pad_unique(), which returns ERR_PTR() on failure but
> never NULL. The previous code only checked for NULL, leading to invalid
> pointer dereference.
>
> Fixes: a564839e630c ("media: subdev: Add v4l2_subdev_get_frame_desc_passthrough helper")
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
> drivers/media/v4l2-core/v4l2-subdev.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> index 9efd14d4026f..7cb17e0a5617 100644
> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> @@ -2585,10 +2585,10 @@ int v4l2_subdev_get_frame_desc_passthrough(struct v4l2_subdev *sd,
>
> if (!have_source_fd) {
> remote_source_pad = media_pad_remote_pad_unique(local_sink_pad);
> - if (!remote_source_pad) {
> + if (IS_ERR(remote_source_pad)) {
> dev_dbg(dev, "Failed to find remote pad for sink pad %u\n",
> local_sink_pad->index);
> - ret = -EINVAL;
> + ret = PTR_ERR(remote_source_pad);
> goto out_unlock;
> }
>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Tomi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-16 7:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-13 6:39 [PATCH] media: v4l2-subdev: Fix error check in v4l2_subdev_get_frame_desc_passthrough() Chen Ni
2026-03-13 15:11 ` Jacopo Mondi
2026-03-16 7:58 ` Tomi Valkeinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox