qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fei Li <fli@suse.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] fix Segmentation fault when emulating a bluetooth device 'dev'
Date: Wed, 30 May 2018 20:53:14 +0800	[thread overview]
Message-ID: <20180530125314.11677-1-fli@suse.com> (raw)

The current code bt_hid_send_data() did not check whether its first
parameter *ch is NULL, which will cause a "Segmentation fault" when
*ch is NULL as ch->remote_mtu will be directly referenced later in
this function. E.g. when called by bt_hid_datain() and hid->interrupt
is NULL with "qemu-system-x86_64 ... \ -bt device:keyboard,vlan=3".

Thus add a judgement to avoid such error.

Signed-off-by: Fei Li <fli@suse.com>
---
 hw/bt/hid.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/bt/hid.c b/hw/bt/hid.c
index 056291f9b5..dfb0ea9c9b 100644
--- a/hw/bt/hid.c
+++ b/hw/bt/hid.c
@@ -174,6 +174,9 @@ static void bt_hid_send_data(struct bt_l2cap_conn_params_s *ch, int type,
     uint8_t *pkt, hdr = (BT_DATA << 4) | type;
     int plen;
 
+    if (!ch)
+        return;
+
     do {
         plen = MIN(len, ch->remote_mtu - 1);
         pkt = ch->sdu_out(ch, plen + 1);
-- 
2.13.6

                 reply	other threads:[~2018-05-30 12:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20180530125314.11677-1-fli@suse.com \
    --to=fli@suse.com \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).