Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more coverity fixes #438

Merged
merged 2 commits into from
Jul 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions v4l2loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ static ssize_t attr_store_format(struct device *cd,
struct v4l2_loopback_device *dev = v4l2loopback_cd2dev(cd);
unsigned int fps_num = 0, fps_den = 1;

if (!dev)
return -ENODEV;

/* only fps changing is supported */
if (sscanf(buf, "@%u/%u", &fps_num, &fps_den) > 0) {
struct v4l2_fract f = { .numerator = fps_den,
Expand All @@ -476,6 +479,9 @@ static ssize_t attr_show_buffers(struct device *cd,
{
struct v4l2_loopback_device *dev = v4l2loopback_cd2dev(cd);

if (!dev)
return -ENODEV;

return sprintf(buf, "%u\n", dev->used_buffers);
}

Expand Down Expand Up @@ -2131,7 +2137,9 @@ v4l2_loopback_add(struct v4l2_loopback_config *conf)
init_vdev(dev->vdev, nr, conf->debug);
dev->vdev->v4l2_dev = &dev->v4l2_dev;
init_capture_param(&dev->capture_param);
set_timeperframe(dev, &dev->capture_param.timeperframe);
err = set_timeperframe(dev, &dev->capture_param.timeperframe);
if (err)
goto out_unregister;
dev->keep_format = 0;
dev->sustain_framerate = 0;

Expand Down Expand Up @@ -2186,6 +2194,8 @@ v4l2_loopback_add(struct v4l2_loopback_config *conf)
dev->v4l2_dev.ctrl_handler = hdl;

err = v4l2_ctrl_handler_setup(hdl);
if (err)
goto out_free_handler;

/* FIXME set buffers to 0 */

Expand All @@ -2200,7 +2210,9 @@ v4l2_loopback_add(struct v4l2_loopback_config *conf)
dev->buffer_size = PAGE_ALIGN(dev->pix_format.sizeimage);
dprintk("buffer_size = %ld (=%u)\n", dev->buffer_size,
dev->pix_format.sizeimage);
allocate_buffers(dev);
err = allocate_buffers(dev);
if (err)
goto out_free_handler;

init_waitqueue_head(&dev->read_event);

Expand Down