[libvirt] [PATCH] conf: Don't deref NULL actual network in virDomainNetGetActualHostdev()

Eric Blake eblake at redhat.com
Wed Sep 4 15:45:53 UTC 2013


On 09/04/2013 09:37 AM, Peter Krempa wrote:
> In commit 991270db99690 I've used virDomainNetGetActualHostdev() to get
> the actual hostdev from a network when removing the network from the
> list to avoid leaving the hostdev in the list. I didn't notice that this
> function doesn't check if the actual network is allocated and
> dereferences it. This crashes the daemon when cleaning up a domain
> object in early startup phases when the actual network definition isn't
> allocated. When the actual definition isn't present, the hostdev that
> might correspond to it won't be present anyways so it's safe to return
> NULL.
> 
> Thanks to Cole Robinson for noticing this problem.
> ---
>  src/conf/domain_conf.c | 1 +
>  1 file changed, 1 insertion(+)

ACK.

> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index cef4cf9..276c6ba 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -17875,6 +17875,7 @@ virDomainNetGetActualHostdev(virDomainNetDefPtr iface)
>      if (iface->type == VIR_DOMAIN_NET_TYPE_HOSTDEV)
>          return &iface->data.hostdev.def;
>      if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
> +        iface->data.network.actual &&
>          iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
>          return &iface->data.network.actual->data.hostdev.def;
>      }
> 

-- 
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: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130904/8e819d29/attachment-0001.sig>


More information about the libvir-list mailing list