Skip to content

Commit 8ac4564

Browse files
ezequielgarciaMauro Carvalho Chehab
authored andcommitted
[media] stk1160: Stop device and unqueue buffers when start_streaming() fails
If start_streaming() fails (e.g. out of memory) the driver needs to rewind the start procedure. This implies possibly stopping the device and clearing the buffer queue. Signed-off-by: Ezequiel Garcia <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent c6b69c6 commit 8ac4564

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

drivers/media/usb/stk1160/stk1160-v4l.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,15 @@ static int stk1160_start_streaming(struct stk1160 *dev)
184184
if (!dev->isoc_ctl.num_bufs || new_pkt_size) {
185185
rc = stk1160_alloc_isoc(dev);
186186
if (rc < 0)
187-
goto out_unlock;
187+
goto out_stop_hw;
188188
}
189189

190190
/* submit urbs and enables IRQ */
191191
for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
192192
rc = usb_submit_urb(dev->isoc_ctl.urb[i], GFP_KERNEL);
193193
if (rc) {
194194
stk1160_err("cannot submit urb[%d] (%d)\n", i, rc);
195-
stk1160_uninit_isoc(dev);
196-
goto out_unlock;
195+
goto out_uninit;
197196
}
198197
}
199198

@@ -206,7 +205,16 @@ static int stk1160_start_streaming(struct stk1160 *dev)
206205

207206
stk1160_dbg("streaming started\n");
208207

209-
out_unlock:
208+
mutex_unlock(&dev->v4l_lock);
209+
210+
return 0;
211+
212+
out_uninit:
213+
stk1160_uninit_isoc(dev);
214+
out_stop_hw:
215+
usb_set_interface(dev->udev, 0, 0);
216+
stk1160_clear_queue(dev);
217+
210218
mutex_unlock(&dev->v4l_lock);
211219

212220
return rc;

0 commit comments

Comments
 (0)