Skip to content

Commit

Permalink
media: stk1160: fix number of buffers in case not all buffers are cre…
Browse files Browse the repository at this point in the history
…ated

In case we fail to allocate a transfer_buffer then we
break the buffers creation loop and update the number of
buffers to the number of successfully allocated which should
be 'i' and not 'i - 1' nor 'i + 1'

Signed-off-by: Dafna Hirschfeld <[email protected]>
Reviewed-by: Ezequiel Garcia <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
Dafna Hirschfeld authored and mchehab committed Mar 7, 2022
1 parent cf1abc5 commit 447b437
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/media/usb/stk1160/stk1160-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,15 +511,15 @@ int stk1160_alloc_isoc(struct stk1160 *dev)
usb_free_urb(dev->isoc_ctl.urb[i]);
dev->isoc_ctl.urb[i] = NULL;

stk1160_warn("%d urbs allocated. Trying to continue...\n", i - 1);
stk1160_warn("%d urbs allocated. Trying to continue...\n", i);

dev->isoc_ctl.num_bufs = i - 1;
dev->isoc_ctl.num_bufs = i;

return 0;

free_i_bufs:
/* Save the allocated buffers so far, so we can properly free them */
dev->isoc_ctl.num_bufs = i+1;
dev->isoc_ctl.num_bufs = i;
stk1160_free_isoc(dev);
return -ENOMEM;
}
Expand Down

0 comments on commit 447b437

Please sign in to comment.