[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] xen: fix memory leak in __xen_pcibk_add_pci_dev()



>>> On 31.03.14 at 12:08, <daeseok.youn@xxxxxxxxx> wrote:

> It need to free dev_entry when it failed to assign to a new
> slot on the virtual PCI bus.
> 
> smatch says:
>  drivers/xen/xen-pciback/vpci.c:142 __xen_pcibk_add_pci_dev() warn:
> possible memory leak of 'dev_entry'
> 
> Signed-off-by: Daeseok Youn <daeseok.youn@xxxxxxxxx>

Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>

albeit the solution is not ideal:

> --- a/drivers/xen/xen-pciback/vpci.c
> +++ b/drivers/xen/xen-pciback/vpci.c
> @@ -130,6 +130,7 @@ static int __xen_pcibk_add_pci_dev(struct 
> xen_pcibk_device *pdev,
>       err = -ENOMEM;
>       xenbus_dev_fatal(pdev->xdev, err,
>                        "No more space on root virtual PCI bus");
> +     kfree(dev_entry);
>  
>  unlock:
>       mutex_unlock(&vpci_dev->lock);

The kfree() invocation would better be placed outside the locked
region (e.g. in an else to the "if (!err)" a little further down).

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.