From patchwork Mon Sep 27 07:52:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 65818 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 458D6B70D5 for ; Mon, 27 Sep 2010 18:05:57 +1000 (EST) Received: from localhost ([127.0.0.1]:33504 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P08ig-0000rY-N0 for incoming@patchwork.ozlabs.org; Mon, 27 Sep 2010 04:05:54 -0400 Received: from [140.186.70.92] (port=37340 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P08eF-000738-QE for qemu-devel@nongnu.org; Mon, 27 Sep 2010 04:01:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P08W7-0001Fn-LD for qemu-devel@nongnu.org; Mon, 27 Sep 2010 03:52:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27497) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P08W7-0001FQ-Ed for qemu-devel@nongnu.org; Mon, 27 Sep 2010 03:52:55 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8R7qqpN008869 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 27 Sep 2010 03:52:52 -0400 Received: from dhcp-91-7.nay.redhat.com.englab.nay.redhat.com (dhcp-91-7.nay.redhat.com [10.66.91.7]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8R7qn6q026740; Mon, 27 Sep 2010 03:52:50 -0400 To: qemu-devel@nongnu.org, anthony@codemonkey.ws, mst@redhat.com From: Jason Wang Date: Mon, 27 Sep 2010 15:52:44 +0800 Message-ID: <20100927075244.8835.530.stgit@dhcp-91-7.nay.redhat.com.englab.nay.redhat.com> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCH] monitor: properly handle invalid fd/vhostfd from command line X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org monitor_get_fd() may also be used to parse fd or vhostfd from command line, so we need to check whether the pointer of mon is NULL to avoid segmentation fault when user pass invalid name of fd or vhostfd. Signed-off-by: Jason Wang Acked-by: Michael S. Tsirkin --- monitor.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/monitor.c b/monitor.c index e602480..5bb4ff0 100644 --- a/monitor.c +++ b/monitor.c @@ -2345,6 +2345,10 @@ int monitor_get_fd(Monitor *mon, const char *fdname) { mon_fd_t *monfd; + if (mon == NULL) { + return -1; + } + QLIST_FOREACH(monfd, &mon->fds, next) { int fd;