From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=42483 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0BMZ-0006v1-DX for qemu-devel@nongnu.org; Mon, 27 Sep 2010 06:55:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P0BMY-0002Hp-3U for qemu-devel@nongnu.org; Mon, 27 Sep 2010 06:55:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14532) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0BMX-0002Hb-SG for qemu-devel@nongnu.org; Mon, 27 Sep 2010 06:55:14 -0400 Date: Mon, 27 Sep 2010 12:49:14 +0200 From: "Michael S. Tsirkin" Message-ID: <20100927104914.GA6695@redhat.com> References: <20100927075244.8835.530.stgit@dhcp-91-7.nay.redhat.com.englab.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100927075244.8835.530.stgit@dhcp-91-7.nay.redhat.com.englab.nay.redhat.com> Subject: [Qemu-devel] Re: [PATCH] monitor: properly handle invalid fd/vhostfd from command line List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jason Wang Cc: qemu-devel@nongnu.org On Mon, Sep 27, 2010 at 03:52:44PM +0800, Jason Wang wrote: > 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; > >