mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/vboxvideo: Avoid double check buffer_overflow in vbva_write()
@ 2019-04-06  8:18 Sidong Yang
  2019-04-06  9:47 ` Hans de Goede
  0 siblings, 1 reply; 2+ messages in thread
From: Sidong Yang @ 2019-04-06  8:18 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Sidong Yang, David Airlie, Daniel Vetter, dri-devel, linux-kernel

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-06  9:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-06  8:18 [PATCH] drm/vboxvideo: Avoid double check buffer_overflow in vbva_write() Sidong Yang
2019-04-06  9:47 ` Hans de Goede

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®