On 20/09/2023 16:30, Benjamin Gaignard wrote:
<snip>
What is the backtrace? How can this happen? It feels wrong that this can beI got kernel crash without them.num_buffers = min_t(unsigned int, num_buffers,I don't think this can ever happen.
q->max_allowed_buffers - vb2_get_num_buffers(q));
- first_index = vb2_get_num_buffers(q);
+ first_index = bitmap_find_next_zero_area(q->bufs_map, q->max_allowed_buffers,
+ 0, num_buffers, 0);
if (first_index >= q->max_allowed_buffers)
return 0;
@@ -675,7 +678,13 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers)
struct vb2_buffer *vb2_get_buffer(struct vb2_queue *q, unsigned int index)
{
- if (index < q->num_buffers)
+ if (!q->bufs_map || !q->bufs)
+ return NULL;
I will keep them.
called with a vb2_queue that apparently is not properly initialized.
Not a problem. E.g. v4l2-ctrls.h is full of such static inlines.vb2_get_num_buffers is defined in videobuf2-core.c, I'm not sure that+How about:
+ return (bitmap_weight(q->bufs_map, q->max_allowed_buffers) > 0);
return vb2_get_num_buffers(q) > 0;
an inline function could depend of a module function.
Regards,
Hans