Commit 896f38f582730a19eb49677105b4fe4c0270b82e

Authored by Ezequiel Garcia
Committed by Mauro Carvalho Chehab
1 parent 4195ec7a8f

[media] videobuf2-core: Replace BUG_ON and return an error at vb2_queue_init()

This replaces BUG_ON() calls with WARN_ON(), and returns
EINVAL if some parameter is NULL, as suggested by Jonathan and Mauro.
The BUG_ON() call is too drastic to be used in this case.
See the full discussion here:
http://www.spinics.net/lists/linux-media/msg52462.html

Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

Showing 2 changed files with 12 additions and 9 deletions Side-by-side Diff

drivers/media/v4l2-core/videobuf2-core.c
... ... @@ -1738,14 +1738,17 @@
1738 1738 */
1739 1739 int vb2_queue_init(struct vb2_queue *q)
1740 1740 {
1741   - BUG_ON(!q);
1742   - BUG_ON(!q->ops);
1743   - BUG_ON(!q->mem_ops);
1744   - BUG_ON(!q->type);
1745   - BUG_ON(!q->io_modes);
1746   -
1747   - BUG_ON(!q->ops->queue_setup);
1748   - BUG_ON(!q->ops->buf_queue);
  1741 + /*
  1742 + * Sanity check
  1743 + */
  1744 + if (WARN_ON(!q) ||
  1745 + WARN_ON(!q->ops) ||
  1746 + WARN_ON(!q->mem_ops) ||
  1747 + WARN_ON(!q->type) ||
  1748 + WARN_ON(!q->io_modes) ||
  1749 + WARN_ON(!q->ops->queue_setup) ||
  1750 + WARN_ON(!q->ops->buf_queue))
  1751 + return -EINVAL;
1749 1752  
1750 1753 INIT_LIST_HEAD(&q->queued_list);
1751 1754 INIT_LIST_HEAD(&q->done_list);
include/media/videobuf2-core.h
... ... @@ -324,7 +324,7 @@
324 324 int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create);
325 325 int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b);
326 326  
327   -int vb2_queue_init(struct vb2_queue *q);
  327 +int __must_check vb2_queue_init(struct vb2_queue *q);
328 328  
329 329 void vb2_queue_release(struct vb2_queue *q);
330 330