From: Sidong Yang <realwakka@gmail.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Sidong Yang <realwakka@gmail.com>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH] drm/vboxvideo: Avoid double check buffer_overflow in vbva_write()
Date: Sat, 6 Apr 2019 08:18:50 +0000 [thread overview]
Message-ID: <20190406081850.1906-1-realwakka@gmail.com> (raw)
In vbva_write(), We do not need to double check available chunk size if
chunk is smaller than available buffer. Put the second if clause in the
first if clause and avoid check twice.
Signed-off-by: Sidong Yang <realwakka@gmail.com>
---
drivers/gpu/drm/vboxvideo/vbva_base.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/vboxvideo/vbva_base.c b/drivers/gpu/drm/vboxvideo/vbva_base.c
index 36bc9824ec3f..a0c185acf37a 100644
--- a/drivers/gpu/drm/vboxvideo/vbva_base.c
+++ b/drivers/gpu/drm/vboxvideo/vbva_base.c
@@ -80,14 +80,14 @@ bool vbva_write(struct vbva_buf_ctx *vbva_ctx, struct gen_pool *ctx,
if (chunk >= available) {
vbva_buffer_flush(ctx);
available = vbva_buffer_available(vbva);
- }
-
- if (chunk >= available) {
- if (WARN_ON(available <= vbva->partial_write_tresh)) {
- vbva_ctx->buffer_overflow = true;
- return false;
+ if (chunk >= available) {
+ if (WARN_ON(available <= vbva->partial_write_tresh)) {
+ vbva_ctx->buffer_overflow = true;
+ return false;
+ }
+ chunk = available - vbva->partial_write_tresh;
}
- chunk = available - vbva->partial_write_tresh;
+
}
vbva_buffer_place_data_at(vbva_ctx, p, chunk,
--
2.11.0
next reply other threads:[~2019-04-06 8:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-06 8:18 Sidong Yang [this message]
2019-04-06 9:47 ` Hans de Goede
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=20190406081850.1906-1-realwakka@gmail.com \
--to=realwakka@gmail.com \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®