From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LApNH-0006zp-UX for qemu-devel@nongnu.org; Thu, 11 Dec 2008 12:30:55 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LApNF-0006zX-8Q for qemu-devel@nongnu.org; Thu, 11 Dec 2008 12:30:54 -0500 Received: from [199.232.76.173] (port=39565 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LApNF-0006zS-03 for qemu-devel@nongnu.org; Thu, 11 Dec 2008 12:30:53 -0500 Received: from savannah.gnu.org ([199.232.41.3]:34261 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LApNE-0003ww-Ma for qemu-devel@nongnu.org; Thu, 11 Dec 2008 12:30:52 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LApNE-0005zF-1A for qemu-devel@nongnu.org; Thu, 11 Dec 2008 17:30:52 +0000 Received: from blueswir1 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LApND-0005zB-ID for qemu-devel@nongnu.org; Thu, 11 Dec 2008 17:30:51 +0000 MIME-Version: 1.0 Errors-To: blueswir1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Blue Swirl Message-Id: Date: Thu, 11 Dec 2008 17:30:51 +0000 Subject: [Qemu-devel] [5978] Allow to register a callback with fw_cfg_add_callback() 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 Revision: 5978 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5978 Author: blueswir1 Date: 2008-12-11 17:30:50 +0000 (Thu, 11 Dec 2008) Log Message: ----------- Allow to register a callback with fw_cfg_add_callback() 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 Modified Paths: -------------- trunk/hw/fw_cfg.c Modified: trunk/hw/fw_cfg.c =================================================================== --- trunk/hw/fw_cfg.c 2008-12-11 17:29:00 UTC (rev 5977) +++ trunk/hw/fw_cfg.c 2008-12-11 17:30:50 UTC (rev 5978) @@ -240,10 +240,12 @@ 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;