Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

media: v4l2-subdev: Fix error check in v4l2_subdev_get_frame_desc_passthrough()

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.

Detected by Smatch:
drivers/media/v4l2-core/v4l2-subdev.c:2588 v4l2_subdev_get_frame_desc_passthrough() warn:
'remote_source_pad' is an error pointer or valid

drivers/media/v4l2-core/v4l2-subdev.c:2595 v4l2_subdev_get_frame_desc_passthrough() error:
'remote_source_pad' dereferencing possible ERR_PTR()

Fixes: a564839e630c ("media: subdev: Add v4l2_subdev_get_frame_desc_passthrough helper")
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>

authored by

Chen Ni and committed by
Hans Verkuil
9f1af89a d3ac6212

+2 -2
+2 -2
drivers/media/v4l2-core/v4l2-subdev.c
··· 2585 2585 2586 2586 if (!have_source_fd) { 2587 2587 remote_source_pad = media_pad_remote_pad_unique(local_sink_pad); 2588 - if (!remote_source_pad) { 2588 + if (IS_ERR(remote_source_pad)) { 2589 2589 dev_dbg(dev, "Failed to find remote pad for sink pad %u\n", 2590 2590 local_sink_pad->index); 2591 - ret = -EINVAL; 2591 + ret = PTR_ERR(remote_source_pad); 2592 2592 goto out_unlock; 2593 2593 } 2594 2594