From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LAnWK-0005bl-Ao for qemu-devel@nongnu.org; Thu, 11 Dec 2008 10:32:08 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LAnWJ-0005b5-Go for qemu-devel@nongnu.org; Thu, 11 Dec 2008 10:32:07 -0500 Received: from [199.232.76.173] (port=33413 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LAnWJ-0005ar-77 for qemu-devel@nongnu.org; Thu, 11 Dec 2008 10:32:07 -0500 Received: from mx2.redhat.com ([66.187.237.31]:42594) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LAnWI-00022I-QH for qemu-devel@nongnu.org; Thu, 11 Dec 2008 10:32:07 -0500 Date: Thu, 11 Dec 2008 17:32:53 +0200 From: Gleb Natapov Subject: Re: [Qemu-devel] [PATCH] Allow to register a callback with fw_cfg_add_callback() Message-ID: <20081211153253.GO5555@redhat.com> References: <1229008168-8012-1-git-send-email-Laurent.Vivier@bull.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1229008168-8012-1-git-send-email-Laurent.Vivier@bull.net> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Laurent Vivier On Thu, Dec 11, 2008 at 04:09:28PM +0100, Laurent Vivier wrote: > fw_cfg_add_callback() checks if key has FW_CFG_WRITE_CHANNEL bit set > after masking the key with FW_CFG_ENTRY_MASK. > > But as FW_CFG_ENTRY_MASK is ~(FW_CFG_WRITE_CHANNEL | FW_CFG_ARCH_LOCAL), > the bit is never set and function exits. > > This patch corrects this by checking the bit before masking the value. > > Signed-by-off: Laurent Vivier Acked-by: Gleb Natapov > --- > hw/fw_cfg.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > Index: qemu/hw/fw_cfg.c > =================================================================== > --- qemu.orig/hw/fw_cfg.c 2008-12-11 15:55:15.000000000 +0100 > +++ qemu/hw/fw_cfg.c 2008-12-11 15:55:41.000000000 +0100 > @@ -240,10 +240,12 @@ int fw_cfg_add_callback(void *opaque, ui > FWCfgState *s = opaque; > int arch = !!(key & FW_CFG_ARCH_LOCAL); > > + if (!(key & FW_CFG_WRITE_CHANNEL)) > + return 0; > + > key &= FW_CFG_ENTRY_MASK; > > - if (key >= FW_CFG_MAX_ENTRY || !(key & FW_CFG_WRITE_CHANNEL) > - || len > 65535) > + if (key >= FW_CFG_MAX_ENTRY || len > 65535) > return 0; > > s->entries[arch][key].data = data; > -- Gleb.