media: subdev: Fix error pointer dereference
PATCH 1/1 media: subdev: Fix error pointer dereference
The function media_pad_remote_pad_unique() returns an error pointer upon failure, not null.
Add check for error pointer and extract the error code with PTR_ERR().
--- drivers/media/v4l2-core/v4l2-subdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/v4l2-core/v4l2-subdev.c +2 -2
@@ -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; }
Signature · 1 line
2.53.0
Quoted 4 lines · Ethan Tidmore
The function
media_pad_remote_pad_unique()returns an error pointer upon failure, not null.Add check for error pointer and extract the error code with
PTR_ERR().
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()
Quoted 4 lines
Fixes a564839e630c1 ("media: subdev: Add v4l2_subdev_get_frame_desc_passthrough helper")Signed-off-by Ethan Tidmore <[email protected]>---
Forgot to add the Smatch warnings, if this version is good please add this to the commit message.
Thanks,
ET
Hi Ethan
Quoted 4 lines · Ethan Tidmore
Quoted 3 lines · Ethan Tidmore
The function
media_pad_remote_pad_unique()returns an error pointer upon failure, not null.
A patch has already been submitted to fix this issue
https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
Quoted 9 lines
Quoted 1 line
Add check for error pointer and extract the error code with
PTR_ERR().Detected by Smatch:
drivers/media/v4l2-core/v4l2-subdev.c:2588v4l2_subdev_get_frame_desc_passthrough()warn:
'remote_source_pad' is an error pointer or valid
drivers/media/v4l2-core/v4l2-subdev.c:2595v4l2_subdev_get_frame_desc_passthrough()error:
'remote_source_pad' dereferencing possibleERR_PTR()
Chen Ni: have you used Smatch as well ? Should you add the above lines to attribute the bug report to it ?
Thanks
j
Quoted 11 lines
Quoted 4 lines
Fixes a564839e630c1 ("media: subdev: Add v4l2_subdev_get_frame_desc_passthrough helper")Signed-off-by Ethan Tidmore <[email protected]>---
Forgot to add the Smatch warnings, if this version is good please add this to the commit message.
Thanks,
ET