[libvirt] [PATCH] Make really sure we don't access non-existing vCPUs

Peter Krempa pkrempa at redhat.com
Tue Jul 12 13:01:57 UTC 2016


On Tue, Jul 12, 2016 at 13:44:10 +0200, Martin Kletzander wrote:
> MinGW complained that we might be dereferencing a NULL pointer.  While

^^ Does anybody use that?

> that's most probably not going to be true (now), the logic certainly
> allows for that and we might actually do this a lot in the future with
> sparse vcpu mapping.
> 
> ../../src/conf/domain_conf.c: In function 'virDomainDefGetVcpuPinInfoHelper':
> ../../src/conf/domain_conf.c:1545:17: error: potential null pointer
> dereference [-Werror=null-dereference]
>          if (vcpu->cpumask)
>               ~~~~^~~~~~~~~
> 
> Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
> ---
> I could've pushed this as a build breaker, but I'm not really sure
> everyone will like this to be handled this way.  I also did another
> fix for this where we don't do int->size_t->int casting all the time,
> but it's probably not worth the hassle.  Also I don't know whether
> Peter has more stuff for this in his pockets now, so I figured I
> rather submit this for review.

It's impossible since virDomainDefGetVcpu returns a valid pointer if i
is less than def->maxvcpus.

Since we are rather adding dead code than not supporting broken
toolchain ... ACK.

> 
>  src/conf/domain_conf.c | 3 +++
>  1 file changed, 3 insertions(+)

Peter




More information about the libvir-list mailing list