All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib/librte_vhost: fix memory leak
@ 2017-01-04  3:57 Yong Wang
  2017-01-04  4:02 ` Yuanhan Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Yong Wang @ 2017-01-04  3:57 UTC (permalink / raw)
  To: yuanhan.liu; +Cc: dev, Yong Wang

In function vhost_new_device(), current code dose not free 'dev'
in "i == MAX_VHOST_DEVICE" condition statements. It will lead to a
memory leak.

Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
---
 lib/librte_vhost/vhost.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index 31825b8..e415093 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -250,6 +250,7 @@ struct virtio_net *
 	if (i == MAX_VHOST_DEVICE) {
 		RTE_LOG(ERR, VHOST_CONFIG,
 			"Failed to find a free slot for new device.\n");
+		rte_free(dev);
 		return -1;
 	}
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] lib/librte_vhost: fix memory leak
  2017-01-04  3:57 [PATCH] lib/librte_vhost: fix memory leak Yong Wang
@ 2017-01-04  4:02 ` Yuanhan Liu
  2017-01-04  6:55   ` 答复: " wang.yong19
  0 siblings, 1 reply; 3+ messages in thread
From: Yuanhan Liu @ 2017-01-04  4:02 UTC (permalink / raw)
  To: Yong Wang; +Cc: dev

On Tue, Jan 03, 2017 at 10:57:55PM -0500, Yong Wang wrote:
> In function vhost_new_device(), current code dose not free 'dev'
> in "i == MAX_VHOST_DEVICE" condition statements. It will lead to a
> memory leak.

Nice catch!

Here are few minor stuff you might need pay attention to for future
contribution:

- a fix patch needs a fixline, like following

  Fixes: 45ca9c6f7bc6 ("vhost: get rid of linked list for devices")

- the prefix for vhost lib is "vhost: ". And FYI, for PMD drivers, it's
  'net/PMD_NAME', say 'net/virtio'.


For you convenience, I have fixed the two while applying. And thanks
for the fix.

Applied to dpdk-next-virtio.

	--yliu

^ permalink raw reply	[flat|nested] 3+ messages in thread

* 答复: Re: [PATCH] lib/librte_vhost: fix memory leak
  2017-01-04  4:02 ` Yuanhan Liu
@ 2017-01-04  6:55   ` wang.yong19
  0 siblings, 0 replies; 3+ messages in thread
From: wang.yong19 @ 2017-01-04  6:55 UTC (permalink / raw)
  To: Yuanhan Liu; +Cc: dev

> Yuanhan Liu <yuanhan.liu@linux.intel.com> 
> 2017/01/04 12:02
> 
> to
> 
> Yong Wang <wang.yong19@zte.com.cn>, 
> 
> cc
> 
> dev@dpdk.org
> 
> subject
> 
> Re: [PATCH] lib/librte_vhost: fix memory leak
> 
> On Tue, Jan 03, 2017 at 10:57:55PM -0500, Yong Wang wrote:
> > In function vhost_new_device(), current code dose not free 'dev'
> > in "i == MAX_VHOST_DEVICE" condition statements. It will lead to a
> > memory leak.
> 
> Nice catch!
> 
> Here are few minor stuff you might need pay attention to for future
> contribution:
> 
> - a fix patch needs a fixline, like following
> 
>   Fixes: 45ca9c6f7bc6 ("vhost: get rid of linked list for devices")
> 
> - the prefix for vhost lib is "vhost: ". And FYI, for PMD drivers, it's
>   'net/PMD_NAME', say 'net/virtio'.
> 
> 
> For you convenience, I have fixed the two while applying. And thanks
> for the fix.
> 
> Applied to dpdk-next-virtio.
> 
>    --yliu

Thanks for your advice. 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-01-04  6:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-04  3:57 [PATCH] lib/librte_vhost: fix memory leak Yong Wang
2017-01-04  4:02 ` Yuanhan Liu
2017-01-04  6:55   ` 答复: " wang.yong19

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.