media: v4l2loopback: fix for dereferenced error
Found the code hasn't check whether some var is NULL before using it in v4l2loopback. Fix those issues. Change-Id: I559ed8c0978cf478ed713761b7bc7e3b21c09ff4 Signed-off-by: Lily Li <lali@codeaurora.org>
This commit is contained in:
parent
fbbb7d9af6
commit
4bbb2def1d
1 changed files with 4 additions and 3 deletions
|
@ -483,6 +483,8 @@ static ssize_t attr_store_format(struct device *cd,
|
||||||
struct v4l2_loopback_device *dev = v4l2loopback_cd2dev(cd);
|
struct v4l2_loopback_device *dev = v4l2loopback_cd2dev(cd);
|
||||||
int fps_num = 0, fps_den = 1;
|
int fps_num = 0, fps_den = 1;
|
||||||
|
|
||||||
|
if (!dev)
|
||||||
|
return -EINVAL;
|
||||||
/* only fps changing is supported */
|
/* only fps changing is supported */
|
||||||
if (sscanf(buf, "@%d/%d", &fps_num, &fps_den) > 0) {
|
if (sscanf(buf, "@%d/%d", &fps_num, &fps_den) > 0) {
|
||||||
struct v4l2_fract f = {
|
struct v4l2_fract f = {
|
||||||
|
@ -490,7 +492,6 @@ static ssize_t attr_store_format(struct device *cd,
|
||||||
.denominator = fps_num
|
.denominator = fps_num
|
||||||
};
|
};
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
err = set_timeperframe(dev, &f);
|
err = set_timeperframe(dev, &f);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
@ -671,7 +672,7 @@ static inline void unset_flags(struct v4l2l_buffer *buffer)
|
||||||
static void vidioc_fill_name(char *buf, int len, int nr)
|
static void vidioc_fill_name(char *buf, int len, int nr)
|
||||||
{
|
{
|
||||||
if (card_label[nr] != NULL)
|
if (card_label[nr] != NULL)
|
||||||
snprintf(buf, len, card_label[nr]);
|
snprintf(buf, len, "%s\n", card_label[nr]);
|
||||||
else
|
else
|
||||||
snprintf(buf, len, "Dummy video device (0x%04X)", nr);
|
snprintf(buf, len, "Dummy video device (0x%04X)", nr);
|
||||||
}
|
}
|
||||||
|
@ -1909,7 +1910,7 @@ static int v4l2_loopback_mmap(struct file *file, struct vm_area_struct *vma)
|
||||||
|
|
||||||
page = (void *)vmalloc_to_page((void *)addr);
|
page = (void *)vmalloc_to_page((void *)addr);
|
||||||
|
|
||||||
if (vm_insert_page(vma, start, page) < 0)
|
if (!page || vm_insert_page(vma, start, page) < 0)
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
|
|
||||||
start += PAGE_SIZE;
|
start += PAGE_SIZE;
|
||||||
|
|
Loading…
Add table
Reference in a new issue