From: Hans Verkuil <hverkuil@xs4all.nl>
To: linux-media@vger.kernel.org
Cc: pawel@osciak.com, s.nawrocki@samsung.com,
m.szyprowski@samsung.com, Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [RFCv4 PATCH 08/11] vb2: q->num_buffers was updated too soon
Date: Sun, 23 Feb 2014 09:36:39 +0100 [thread overview]
Message-ID: <5309B317.3060603@xs4all.nl> (raw)
In-Reply-To: <1392374472-18393-9-git-send-email-hverkuil@xs4all.nl>
On 02/14/2014 11:41 AM, Hans Verkuil wrote:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> In __reqbufs() and __create_bufs() the q->num_buffers field was updated
> with the number of newly allocated buffers, but right after that those are
> freed again if some error had occurred before. Move the line updating
> num_buffers to *after* that error check.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
NACK: this is actually correct behavior since __vb2_queue_free() subtracts
'allocated_buffers' from q->num_buffers. A comment mentioning this might be
useful, though.
Regards,
Hans
> ---
> drivers/media/v4l2-core/videobuf2-core.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
> index ad3db83..96c5ac6 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -848,13 +848,13 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
> */
> }
>
> - q->num_buffers = allocated_buffers;
> -
> if (ret < 0) {
> __vb2_queue_free(q, allocated_buffers);
> return ret;
> }
>
> + q->num_buffers = allocated_buffers;
> +
> /*
> * Return the number of successfully allocated buffers
> * to the userspace.
> @@ -957,13 +957,13 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create
> */
> }
>
> - q->num_buffers += allocated_buffers;
> -
> if (ret < 0) {
> __vb2_queue_free(q, allocated_buffers);
> return -ENOMEM;
> }
>
> + q->num_buffers += allocated_buffers;
> +
> /*
> * Return the number of successfully allocated buffers
> * to the userspace.
>
next prev parent reply other threads:[~2014-02-23 8:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-14 10:41 [RFCv4 PATCH 00/11] vb2: fixes, balancing callbacks Hans Verkuil
2014-02-14 10:41 ` [RFCv4 PATCH 01/11] vb2: add debugging code to check for unbalanced ops Hans Verkuil
2014-02-14 10:41 ` [RFCv4 PATCH 02/11] vb2: change result code of buf_finish to void Hans Verkuil
2014-02-14 10:41 ` [RFCv4 PATCH 03/11] vb2: add note that buf_finish can be called with !vb2_is_streaming() Hans Verkuil
2014-02-14 10:41 ` [RFCv4 PATCH 04/11] vb2: call buf_finish from __dqbuf Hans Verkuil
2014-02-14 10:41 ` [RFCv4 PATCH 05/11] vb2: fix buf_init/buf_cleanup call sequences Hans Verkuil
2014-02-14 10:41 ` [RFCv4 PATCH 06/11] vb2: fix read/write regression Hans Verkuil
2014-02-14 10:41 ` [RFCv4 PATCH 07/11] vb2: rename queued_count to owned_by_drv_count Hans Verkuil
2014-02-14 10:41 ` [RFCv4 PATCH 08/11] vb2: q->num_buffers was updated too soon Hans Verkuil
2014-02-23 8:36 ` Hans Verkuil [this message]
2014-02-14 10:41 ` [RFCv4 PATCH 09/11] vb2: only call start_streaming if sufficient buffers are queued Hans Verkuil
2014-02-23 8:57 ` Hans Verkuil
2014-02-14 10:41 ` [RFCv4 PATCH 10/11] vivi: correctly cleanup after a start_streaming failure Hans Verkuil
2014-02-14 10:41 ` [RFCv4 PATCH 11/11] v4l2-ioctl: add CREATE_BUFS sanity checks Hans Verkuil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5309B317.3060603@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=hans.verkuil@cisco.com \
--cc=linux-media@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=pawel@osciak.com \
--cc=s.nawrocki@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox