media: stk1160: fix number of buffers in case not all buffers are created

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 <dafna.hirschfeld@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
This commit is contained in:
Dafna Hirschfeld 2022-01-25 09:02:10 +01:00 коммит произвёл Mauro Carvalho Chehab
Родитель cf1abc501a
Коммит 447b437f3f
1 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -511,15 +511,15 @@ nomore_tx_bufs:
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;
}