Skip to content

Commit

Permalink
UBUNTU: SAUCE: coverity: fix null pointer dereference
Browse files Browse the repository at this point in the history
(backported from /pull/438 commit
8245707)
Signed-off-by: You-Sheng Yang <vicamo@gmail.com>

Gbp-Pq: Name 0015-coverity-fix-null-pointer-dereference.patch
  • Loading branch information
vicamo authored and umlaeute committed Aug 4, 2022
1 parent b434b7b commit cd600a3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion v4l2loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ static ssize_t attr_store_format(struct device *cd,
struct v4l2_loopback_device *dev = v4l2loopback_cd2dev(cd);
int fps_num = 0, fps_den = 1;

if (!dev)
return -ENODEV;

/* only fps changing is supported */
if (sscanf(buf, "@%d/%d", &fps_num, &fps_den) > 0) {
struct v4l2_fract f = { .numerator = fps_den,
Expand All @@ -545,6 +548,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, "%d\n", dev->used_buffers);
}

Expand All @@ -555,6 +561,9 @@ static ssize_t attr_show_maxopeners(struct device *cd,
{
struct v4l2_loopback_device *dev = v4l2loopback_cd2dev(cd);

if (!dev)
return -ENODEV;

return sprintf(buf, "%d\n", dev->max_openers);
}

Expand All @@ -569,6 +578,8 @@ static ssize_t attr_store_maxopeners(struct device *cd,
return -EINVAL;

dev = v4l2loopback_cd2dev(cd);
if (!dev)
return -ENODEV;

if (dev->max_openers == curr)
return len;
Expand Down Expand Up @@ -1209,7 +1220,7 @@ static int vidioc_queryctrl(struct file *file, void *fh,
if (!cnf)
BUG();

strcpy(q->name, cnf->name);
strlcpy(q->name, cnf->name, sizeof(q->name));
q->default_value = cnf->def;
q->type = cnf->type;
q->minimum = cnf->min;
Expand Down

0 comments on commit cd600a3

Please sign in to comment.