* [Qemu-trivial] [PATCH] hw/net/xen_nic.c: Free 'netdev->txs' when map 'netdev->rxs' fails
@ 2014-12-16 20:48 ` Chen Gang
0 siblings, 0 replies; 4+ messages in thread
From: Chen Gang @ 2014-12-16 20:48 UTC (permalink / raw)
To: qemu-devel, QEMU Trivial
When map 'netdev->rxs' fails, need free the original resource, or will
cause resource leak.
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
hw/net/xen_nic.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c
index 63918ae..7a57feb 100644
--- a/hw/net/xen_nic.c
+++ b/hw/net/xen_nic.c
@@ -370,11 +370,16 @@ static int net_connect(struct XenDevice *xendev)
netdev->xendev.dom,
netdev->tx_ring_ref,
PROT_READ | PROT_WRITE);
+ if (!netdev->txs) {
+ return -1;
+ }
netdev->rxs = xc_gnttab_map_grant_ref(netdev->xendev.gnttabdev,
netdev->xendev.dom,
netdev->rx_ring_ref,
PROT_READ | PROT_WRITE);
- if (!netdev->txs || !netdev->rxs) {
+ if (!netdev->rxs) {
+ xc_gnttab_munmap(netdev->xendev.gnttabdev, netdev->txs, 1);
+ netdev->txs = NULL;
return -1;
}
BACK_RING_INIT(&netdev->tx_ring, netdev->txs, XC_PAGE_SIZE);
--
1.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH] hw/net/xen_nic.c: Free 'netdev->txs' when map 'netdev->rxs' fails
@ 2014-12-16 20:48 ` Chen Gang
0 siblings, 0 replies; 4+ messages in thread
From: Chen Gang @ 2014-12-16 20:48 UTC (permalink / raw)
To: qemu-devel, QEMU Trivial
When map 'netdev->rxs' fails, need free the original resource, or will
cause resource leak.
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
hw/net/xen_nic.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c
index 63918ae..7a57feb 100644
--- a/hw/net/xen_nic.c
+++ b/hw/net/xen_nic.c
@@ -370,11 +370,16 @@ static int net_connect(struct XenDevice *xendev)
netdev->xendev.dom,
netdev->tx_ring_ref,
PROT_READ | PROT_WRITE);
+ if (!netdev->txs) {
+ return -1;
+ }
netdev->rxs = xc_gnttab_map_grant_ref(netdev->xendev.gnttabdev,
netdev->xendev.dom,
netdev->rx_ring_ref,
PROT_READ | PROT_WRITE);
- if (!netdev->txs || !netdev->rxs) {
+ if (!netdev->rxs) {
+ xc_gnttab_munmap(netdev->xendev.gnttabdev, netdev->txs, 1);
+ netdev->txs = NULL;
return -1;
}
BACK_RING_INIT(&netdev->tx_ring, netdev->txs, XC_PAGE_SIZE);
--
1.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-trivial] [Qemu-devel] [PATCH] hw/net/xen_nic.c: Free 'netdev->txs' when map 'netdev->rxs' fails
2014-12-16 20:48 ` [Qemu-devel] " Chen Gang
@ 2015-01-07 16:01 ` Stefan Hajnoczi
-1 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2015-01-07 16:01 UTC (permalink / raw)
To: Chen Gang; +Cc: QEMU Trivial, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 399 bytes --]
On Wed, Dec 17, 2014 at 04:48:54AM +0800, Chen Gang wrote:
> When map 'netdev->rxs' fails, need free the original resource, or will
> cause resource leak.
>
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> ---
> hw/net/xen_nic.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
Thanks, applied to my net tree:
https://github.com/stefanha/qemu/commits/net
Stefan
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/net/xen_nic.c: Free 'netdev->txs' when map 'netdev->rxs' fails
@ 2015-01-07 16:01 ` Stefan Hajnoczi
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2015-01-07 16:01 UTC (permalink / raw)
To: Chen Gang; +Cc: QEMU Trivial, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 399 bytes --]
On Wed, Dec 17, 2014 at 04:48:54AM +0800, Chen Gang wrote:
> When map 'netdev->rxs' fails, need free the original resource, or will
> cause resource leak.
>
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> ---
> hw/net/xen_nic.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
Thanks, applied to my net tree:
https://github.com/stefanha/qemu/commits/net
Stefan
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-07 16:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-16 20:48 [Qemu-trivial] [PATCH] hw/net/xen_nic.c: Free 'netdev->txs' when map 'netdev->rxs' fails Chen Gang
2014-12-16 20:48 ` [Qemu-devel] " Chen Gang
2015-01-07 16:01 ` [Qemu-trivial] " Stefan Hajnoczi
2015-01-07 16:01 ` Stefan Hajnoczi
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.