From patchwork Thu Aug 11 12:25:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 109604 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7DB7DB70B9 for ; Thu, 11 Aug 2011 22:23:41 +1000 (EST) Received: from localhost ([::1]:49949 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrUIU-0001SI-JA for incoming@patchwork.ozlabs.org; Thu, 11 Aug 2011 08:23:38 -0400 Received: from eggs.gnu.org ([140.186.70.92]:35980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrUIB-0001BG-Nb for qemu-devel@nongnu.org; Thu, 11 Aug 2011 08:23:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QrUI7-0006T8-2O for qemu-devel@nongnu.org; Thu, 11 Aug 2011 08:23:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6124) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrUI6-0006Sy-PV for qemu-devel@nongnu.org; Thu, 11 Aug 2011 08:23:14 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7BCNE42008982 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 11 Aug 2011 08:23:14 -0400 Received: from shalem.localdomain.com (vpn1-5-213.ams2.redhat.com [10.36.5.213]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p7BCN6f1023599; Thu, 11 Aug 2011 08:23:13 -0400 From: Hans de Goede To: Gerd Hoffmann Date: Thu, 11 Aug 2011 14:25:15 +0200 Message-Id: <1313065515-3815-5-git-send-email-hdegoede@redhat.com> In-Reply-To: <1313065515-3815-1-git-send-email-hdegoede@redhat.com> References: <1313065515-3815-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Hans de Goede , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 5/5] usb-redir: Don't try to write to the chardev after a close event 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 Sicne we handle close async in a bh, do_write and thus write can get called after receiving a close event. This patch adds a check to the usb-redir write callback to not do a qemu_chr_write on a closed chardev. Signed-off-by: Hans de Goede --- usb-redir.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/usb-redir.c b/usb-redir.c index 6d8f986..732ddab 100644 --- a/usb-redir.c +++ b/usb-redir.c @@ -226,7 +226,7 @@ static int usbredir_write(void *priv, uint8_t *data, int count) USBRedirDevice *dev = priv; int r; - if (dev->cs->write_blocked) { + if (!dev->cs->opened || dev->cs->write_blocked) { return 0; }