qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: minyard@acm.org
To: qemu-devel@nongnu.org
Cc: bcketchum@gmail.com, Corey Minyard <cminyard@mvista.com>,
	hwd@huawei.com, afaerber@suse.de, mst@redhat.com
Subject: [Qemu-devel] [PATCH 7/7] console: Don't use the console if NULL
Date: Tue,  4 Mar 2014 18:38:57 -0600	[thread overview]
Message-ID: <1393979937-9082-8-git-send-email-minyard@acm.org> (raw)
In-Reply-To: <1393979937-9082-1-git-send-email-minyard@acm.org>

From: Corey Minyard <cminyard@mvista.com>

Two spots used an allocated console, even though new_console could
return NULL.  Check the return value first.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
 ui/console.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/ui/console.c b/ui/console.c
index a204ce2..8d4ca81 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1582,6 +1582,9 @@ QemuConsole *graphic_console_init(DeviceState *dev,
     ds = get_alloc_displaystate();
     trace_console_gfx_new();
     s = new_console(ds, GRAPHIC_CONSOLE);
+    if (!s) {
+        return NULL;
+    }
     s->hw_ops = hw_ops;
     s->hw = opaque;
     if (dev) {
@@ -1747,7 +1750,9 @@ static void text_console_init(CharDriverState *chr, ChardevVC *vc, Error **errp)
         s = new_console(NULL, TEXT_CONSOLE);
     } else {
         s = new_console(NULL, TEXT_CONSOLE_FIXED_SIZE);
-        s->surface = qemu_create_displaysurface(width, height);
+        if (s) {
+            s->surface = qemu_create_displaysurface(width, height);
+        }
     }
 
     if (!s) {
-- 
1.8.3.1

      parent reply	other threads:[~2014-03-05  0:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-05  0:38 [Qemu-devel] [PATCH 0/7] Allow a client chardev to reconnect if disconnected minyard
2014-03-05  0:38 ` [Qemu-devel] [PATCH 1/7] qemu-char: Allocate CharDriverState in qemu_chr_new_from_opts minyard
2014-03-05  0:38 ` [Qemu-devel] [PATCH 2/7] qemu-char: Allow a chardev to reconnect if disconnected minyard
2014-03-06  6:47   ` Weidong Huang
2014-03-06 17:18     ` Corey Minyard
2014-03-06 17:41       ` Michael S. Tsirkin
2014-03-06  7:43   ` Michael S. Tsirkin
2014-03-06 18:04     ` Corey Minyard
2014-03-06 18:43       ` Michael S. Tsirkin
2014-03-05  0:38 ` [Qemu-devel] [PATCH 3/7] qemu-char: Wait until socket connect to report connected minyard
2014-03-05  0:38 ` [Qemu-devel] [PATCH 4/7] qemu-char: remove free of chr from win_stdio_close minyard
2014-03-05  0:38 ` [Qemu-devel] [PATCH 5/7] qemu-char: Close fd at end of file minyard
2014-03-05  0:38 ` [Qemu-devel] [PATCH 6/7] qemu-char: Clean up error handling in qmp_chardev_add minyard
2014-03-05  0:38 ` minyard [this message]

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=1393979937-9082-8-git-send-email-minyard@acm.org \
    --to=minyard@acm.org \
    --cc=afaerber@suse.de \
    --cc=bcketchum@gmail.com \
    --cc=cminyard@mvista.com \
    --cc=hwd@huawei.com \
    --cc=mst@redhat.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).