]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
hw/xen/xen_pt: fix uninitialized variable
authorMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Fri, 27 Jan 2023 05:08:14 +0000 (06:08 +0100)
committerAnthony PERARD <anthony.perard@citrix.com>
Mon, 6 Mar 2023 11:27:37 +0000 (11:27 +0000)
xen_pt_config_reg_init() reads only that many bytes as the size of the
register that is being initialized. It uses
xen_host_pci_get_{byte,word,long} and casts its last argument to
expected pointer type. This means for smaller registers higher bits of
'val' are not initialized. Then, the function fails if any of those
higher bits are set.

Fix this by initializing 'val' with zero.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Message-Id: <20230127050815.4155276-1-marmarek@invisiblethingslab.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
hw/xen/xen_pt_config_init.c

index cde898b7442b949755bdf41d7501b8268bbf88db..8b9b554352fce13dbd73b13808155c22b80963a5 100644 (file)
@@ -1924,7 +1924,7 @@ static void xen_pt_config_reg_init(XenPCIPassthroughState *s,
     if (reg->init) {
         uint32_t host_mask, size_mask;
         unsigned int offset;
-        uint32_t val;
+        uint32_t val = 0;
 
         /* initialize emulate register */
         rc = reg->init(s, reg_entry->reg,