qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: 田殿臣 <dianchen.tdc@gmail.com>
To: qemu-devel@nongnu.org
Cc: icymemo@gmail.com, quan.xu0@gmail.com
Subject: [Qemu-devel] [PATCH] input: free InputEvent when it can't be inserted into a full kdb queue
Date: Wed, 6 Dec 2017 10:29:34 +0800	[thread overview]
Message-ID: <CABkJTM4RL4cZ0euYX7d8xPd7ozrN76nr0rafut0LBJmZWFD+Vw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1079 bytes --]

>From e8c03f405c2112428e79bb82064c7b7743d0cc86 Mon Sep 17 00:00:00 2001
From: Tian Dianchen <dianchen.tdc@gmail.com>
Date: Tue, 5 Dec 2017 14:03:53 +0800
Subject: [PATCH] input: free InputEvent when it can't be inserted into a
full
 kdb queue

When the kdb queue is full, the evt can't be placed in it, so it should
be released to free the memory.

Impact: Without this limit vnc clients can exhaust host memory by keep
sending keyboard events when kdb queue is full.

Reviewed-by: Zhang Chao <icymemo@gmail.com>
Reviewed-by: Quan Xu <quan.xu0@gmail.com>
Signed-off-by: Tian Dianchen <dianchen.tdc@gmail.com>
---
 ui/input.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ui/input.c b/ui/input.c
index 3e2d324..e5b78aa 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -421,6 +421,8 @@ void qemu_input_event_send_key(QemuConsole *src,
KeyValue *key, bool down)
     } else if (queue_count < queue_limit) {
         qemu_input_queue_event(&kbd_queue, src, evt);
         qemu_input_queue_sync(&kbd_queue);
+    } else {
+        qapi_free_InputEvent(evt);
     }
 }

-- 
1.8.3.1

[-- Attachment #2: 0001-input-free-InputEvent-when-it-can-t-be-inserted-into.patch --]
[-- Type: application/octet-stream, Size: 1080 bytes --]

From e8c03f405c2112428e79bb82064c7b7743d0cc86 Mon Sep 17 00:00:00 2001
From: Tian Dianchen <dianchen.tdc@gmail.com>
Date: Tue, 5 Dec 2017 14:03:53 +0800
Subject: [PATCH] input: free InputEvent when it can't be inserted into a full
 kdb queue

When the kdb queue is full, the evt can't be placed in it, so it should
be released to free the memory.

Impact: Without this limit vnc clients can exhaust host memory by keep
sending keyboard events when kdb queue is full.

Reviewed-by: Zhang Chao <icymemo@gmail.com>
Reviewed-by: Quan Xu <quan.xu0@gmail.com>
Signed-off-by: Tian Dianchen <dianchen.tdc@gmail.com>
---
 ui/input.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ui/input.c b/ui/input.c
index 3e2d324..e5b78aa 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -421,6 +421,8 @@ void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down)
     } else if (queue_count < queue_limit) {
         qemu_input_queue_event(&kbd_queue, src, evt);
         qemu_input_queue_sync(&kbd_queue);
+    } else {
+        qapi_free_InputEvent(evt);
     }
 }
 
-- 
1.8.3.1


             reply	other threads:[~2017-12-06  2:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-06  2:29 田殿臣 [this message]
2017-12-06  9:46 ` [Qemu-devel] [PATCH] input: free InputEvent when it can't be inserted into a full kdb queue Marc-André Lureau
2017-12-07  2:38   ` Tian Dianchen
2018-03-02 14:05   ` Quan Xu

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=CABkJTM4RL4cZ0euYX7d8xPd7ozrN76nr0rafut0LBJmZWFD+Vw@mail.gmail.com \
    --to=dianchen.tdc@gmail.com \
    --cc=icymemo@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quan.xu0@gmail.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;
as well as URLs for NNTP newsgroup(s).