From patchwork Thu Apr 19 20:27:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Weil X-Patchwork-Id: 153862 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0D509B6FE6 for ; Fri, 20 Apr 2012 06:27:29 +1000 (EST) Received: from localhost ([::1]:46276 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKxws-0008DG-SR for incoming@patchwork.ozlabs.org; Thu, 19 Apr 2012 16:27:26 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53563) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKxwl-0008DB-Vp for qemu-devel@nongnu.org; Thu, 19 Apr 2012 16:27:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SKxwk-0000ju-20 for qemu-devel@nongnu.org; Thu, 19 Apr 2012 16:27:19 -0400 Received: from v220110690675601.yourvserver.net ([78.47.199.172]:56579) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKxwj-0000jn-Ry for qemu-devel@nongnu.org; Thu, 19 Apr 2012 16:27:17 -0400 Received: from localhost (v220110690675601.yourvserver.net.local [127.0.0.1]) by v220110690675601.yourvserver.net (Postfix) with ESMTP id BDEC572800B3; Thu, 19 Apr 2012 22:27:15 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at weilnetz.de Received: from v220110690675601.yourvserver.net ([127.0.0.1]) by localhost (v220110690675601.yourvserver.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ASA9BMKrJM6a; Thu, 19 Apr 2012 22:27:15 +0200 (CEST) Received: by v220110690675601.yourvserver.net (Postfix, from userid 1000) id 6530F72800B5; Thu, 19 Apr 2012 22:27:15 +0200 (CEST) From: Stefan Weil To: qemu-devel@nongnu.org Date: Thu, 19 Apr 2012 22:27:14 +0200 Message-Id: <1334867234-22885-1-git-send-email-sw@weilnetz.de> X-Mailer: git-send-email 1.7.9 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 78.47.199.172 Cc: Stefan Weil , Anthony Liguori Subject: [Qemu-devel] [PATCH] qemu-char: Fix crash when switching consoles X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org qemu-system-arm (and other system emulations) crashes with SDL when the user switches consoles (Alt-Ctrl-F4). We already check for NULL pointers in qemu_chr_fe_ioctl, qemu_chr_be_can_write and other functions, so do this also for s->chr_read in qemu_chr_be_write. This fixes the crash. Signed-off-by: Stefan Weil --- qemu-char.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 287e195..43adcb2 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -160,7 +160,9 @@ int qemu_chr_be_can_write(CharDriverState *s) void qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len) { - s->chr_read(s->handler_opaque, buf, len); + if (s->chr_read) { + s->chr_read(s->handler_opaque, buf, len); + } } int qemu_chr_fe_get_msgfd(CharDriverState *s)