[libvirt] [PATCH] cmdFreepages: initialize @tmp

Eric Blake eblake at redhat.com
Mon Jun 23 19:02:08 UTC 2014


On 06/23/2014 12:34 PM, Michal Privoznik wrote:
> In the 404bac14 the @tmp variable was introduced. It's purpose is to
> avoid typecasting when parsing --pagesize argument. However, if the
> argument is not presented, tmp may be used uninitialized resulting in
> bogus virNodeGetFreePages() API call:
> 
> virsh freepages --cellno 2
> error: Failed to open file '/sys/devices/system/node/node2/hugepages/hugepages-4294967295kB/free_hugepages': No such file or directory
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  tools/virsh-host.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

ACK

> 
> diff --git a/tools/virsh-host.c b/tools/virsh-host.c
> index 13d4c5c..734f1a8 100644
> --- a/tools/virsh-host.c
> +++ b/tools/virsh-host.c
> @@ -229,7 +229,7 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)
>      bool ret = false;
>      unsigned int npages;
>      unsigned int *pagesize = NULL;
> -    unsigned long long tmp;
> +    unsigned long long tmp = 0;
>      int cell;
>      unsigned long long *counts = NULL;
>      size_t i, j;
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140623/29aca251/attachment-0001.sig>


More information about the libvir-list mailing list