[PATCH] src: Initialize stack allocated virPCIDeviceAddress variables

Jiri Denemark jdenemar at redhat.com
Fri Feb 11 13:44:48 UTC 2022


On Fri, Feb 11, 2022 at 14:36:51 +0100, Michal Privoznik wrote:
> There are few places where a virPCIDeviceAddress typed variable
> is allocated on the stack but it's not initialized. This can lead
> to random values of its members which in turn can lead to a
> random behaviour.
> 
> Generated with help of the following spatch:
> 
>   @@
>   identifier I;
>   @@
>   - virPCIDeviceAddress I;
>   + virPCIDeviceAddress I = { 0 };
> 
> And then fixing bhyveAssignDevicePCISlots() which does declare
> the variable and then explicitly zero it by calling memset() only
> to set a specific member afterwards.
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/bhyve/bhyve_device.c           | 5 +----
>  src/conf/domain_addr.c             | 2 +-
>  src/conf/node_device_conf.c        | 4 ++--
>  src/hypervisor/domain_driver.c     | 6 +++---
>  src/node_device/node_device_udev.c | 2 +-
>  src/qemu/qemu_domain_address.c     | 4 ++--
>  src/util/virpci.c                  | 2 +-
>  7 files changed, 11 insertions(+), 14 deletions(-)

Reviewed-by: Jiri Denemark <jdenemar at redhat.com>




More information about the libvir-list mailing list