[libvirt] [PATCH 2/9] Initialize the stubDriver of pci devices if bound to a valid one

Peter Krempa pkrempa at redhat.com
Mon Nov 2 08:43:39 UTC 2015


On Mon, Nov 02, 2015 at 03:19:13 +0530, Shivaprasad G Bhat wrote:
> The stubDriver name can be used to make useful decisions if readily available.
> Set it if bound to a valid one during initialisation.
> 
> Signed-off-by: Shivaprasad G Bhat <sbhat at linux.vnet.ibm.com>
> ---
>  src/util/virpci.c |    9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/src/util/virpci.c b/src/util/virpci.c
> index f3b4700..be1b6de 100644
> --- a/src/util/virpci.c
> +++ b/src/util/virpci.c
> @@ -1564,6 +1564,8 @@ virPCIDeviceNew(unsigned int domain,
>      virPCIDevicePtr dev;
>      char *vendor = NULL;
>      char *product = NULL;
> +    char *drvpath = NULL;
> +    char *driver = NULL;
>  
>      if (VIR_ALLOC(dev) < 0)
>          return NULL;
> @@ -1611,9 +1613,16 @@ virPCIDeviceNew(unsigned int domain,
>          goto error;
>      }
>  
> +    if (virPCIDeviceGetDriverPathAndName(dev, &drvpath, &driver) < 0)
> +        goto cleanup;

This allocates 'driver'.

> +
> +    if (virPCIIsAKnownStub(driver))

So if the driver is not 'stub'.

> +        dev->stubDriver = driver;

This doesn't get set.

> +
>      VIR_DEBUG("%s %s: initialized", dev->id, dev->name);
>  
>   cleanup:
> +    VIR_FREE(drvpath);

And here it will leak the driver.

>      VIR_FREE(product);
>      VIR_FREE(vendor);
>      return dev;

Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20151102/22b49cc6/attachment-0001.sig>


More information about the libvir-list mailing list