Commit af0321a5 authored by Evgeny Novikov's avatar Evgeny Novikov Committed by Mauro Carvalho Chehab

media: zr364xx: propagate errors from zr364xx_start_readpipe()

zr364xx_start_readpipe() can fail but callers do not care about that.
This can result in various negative consequences. The patch adds missed
error handling.

Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: default avatarEvgeny Novikov <novikov@ispras.ru>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 1671d4ea
...@@ -1327,6 +1327,7 @@ static int zr364xx_board_init(struct zr364xx_camera *cam) ...@@ -1327,6 +1327,7 @@ static int zr364xx_board_init(struct zr364xx_camera *cam)
{ {
struct zr364xx_pipeinfo *pipe = cam->pipe; struct zr364xx_pipeinfo *pipe = cam->pipe;
unsigned long i; unsigned long i;
int err;
DBG("board init: %p\n", cam); DBG("board init: %p\n", cam);
memset(pipe, 0, sizeof(*pipe)); memset(pipe, 0, sizeof(*pipe));
...@@ -1359,9 +1360,8 @@ static int zr364xx_board_init(struct zr364xx_camera *cam) ...@@ -1359,9 +1360,8 @@ static int zr364xx_board_init(struct zr364xx_camera *cam)
if (i == 0) { if (i == 0) {
printk(KERN_INFO KBUILD_MODNAME ": out of memory. Aborting\n"); printk(KERN_INFO KBUILD_MODNAME ": out of memory. Aborting\n");
kfree(cam->pipe->transfer_buffer); err = -ENOMEM;
cam->pipe->transfer_buffer = NULL; goto err_free;
return -ENOMEM;
} else } else
cam->buffer.dwFrames = i; cam->buffer.dwFrames = i;
...@@ -1376,9 +1376,17 @@ static int zr364xx_board_init(struct zr364xx_camera *cam) ...@@ -1376,9 +1376,17 @@ static int zr364xx_board_init(struct zr364xx_camera *cam)
/*** end create system buffers ***/ /*** end create system buffers ***/
/* start read pipe */ /* start read pipe */
zr364xx_start_readpipe(cam); err = zr364xx_start_readpipe(cam);
if (err)
goto err_free;
DBG(": board initialized\n"); DBG(": board initialized\n");
return 0; return 0;
err_free:
kfree(cam->pipe->transfer_buffer);
cam->pipe->transfer_buffer = NULL;
return err;
} }
static int zr364xx_probe(struct usb_interface *intf, static int zr364xx_probe(struct usb_interface *intf,
...@@ -1575,10 +1583,19 @@ static int zr364xx_resume(struct usb_interface *intf) ...@@ -1575,10 +1583,19 @@ static int zr364xx_resume(struct usb_interface *intf)
if (!cam->was_streaming) if (!cam->was_streaming)
return 0; return 0;
zr364xx_start_readpipe(cam); res = zr364xx_start_readpipe(cam);
if (res)
return res;
res = zr364xx_prepare(cam); res = zr364xx_prepare(cam);
if (!res) if (res)
zr364xx_start_acquire(cam); goto err_prepare;
zr364xx_start_acquire(cam);
return 0;
err_prepare:
zr364xx_stop_readpipe(cam);
return res; return res;
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment