* [PATCH] xen: fix memory leak in __xen_pcibk_add_pci_dev()
@ 2014-03-31 10:08 Daeseok Youn
2014-04-01 7:23 ` [Xen-devel] " Jan Beulich
0 siblings, 1 reply; 3+ messages in thread
From: Daeseok Youn @ 2014-03-31 10:08 UTC (permalink / raw)
To: konrad.wilk; +Cc: boris.ostrovsky, david.vrabel, joe, xen-devel, linux-kernel
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@gmail.com>
---
drivers/xen/xen-pciback/vpci.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/xen/xen-pciback/vpci.c b/drivers/xen/xen-pciback/vpci.c
index 3165ce3..657e50f 100644
--- 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);
--
1.7.4.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Xen-devel] [PATCH] xen: fix memory leak in __xen_pcibk_add_pci_dev()
2014-03-31 10:08 [PATCH] xen: fix memory leak in __xen_pcibk_add_pci_dev() Daeseok Youn
@ 2014-04-01 7:23 ` Jan Beulich
2014-04-01 8:17 ` DaeSeok Youn
0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2014-04-01 7:23 UTC (permalink / raw)
To: Daeseok Youn, konrad.wilk
Cc: david.vrabel, xen-devel, boris.ostrovsky, joe, linux-kernel
>>> On 31.03.14 at 12:08, <daeseok.youn@gmail.com> 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@gmail.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Xen-devel] [PATCH] xen: fix memory leak in __xen_pcibk_add_pci_dev()
2014-04-01 7:23 ` [Xen-devel] " Jan Beulich
@ 2014-04-01 8:17 ` DaeSeok Youn
0 siblings, 0 replies; 3+ messages in thread
From: DaeSeok Youn @ 2014-04-01 8:17 UTC (permalink / raw)
To: Jan Beulich
Cc: konrad.wilk, david.vrabel, xen-devel, boris.ostrovsky,
Joe Perches, linux-kernel
2014-04-01 16:23 GMT+09:00 Jan Beulich <JBeulich@suse.com>:
>>>> On 31.03.14 at 12:08, <daeseok.youn@gmail.com> 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@gmail.com>
>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
>
> 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).
You're right.
I will change my patch as your comment and send it again.
Thanks for review.
Daeseok Youn
>
> Jan
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-04-01 8:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-31 10:08 [PATCH] xen: fix memory leak in __xen_pcibk_add_pci_dev() Daeseok Youn
2014-04-01 7:23 ` [Xen-devel] " Jan Beulich
2014-04-01 8:17 ` DaeSeok Youn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®