hw/net/xen_nic.c: Free 'netdev->txs' when map 'netdev->rxs' fails
PATCH 1/1 hw/net/xen_nic.c: Free 'netdev->txs' when map 'netdev->rxs' fails
When map 'netdev->rxs' fails, need free the original resource, or will cause resource leak.
Signed-off-by Chen Gang <[email protected]>
--- hw/net/xen_nic.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
hw/net/xen_nic.c +6 -1
@@ -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 );
Signature · 1 line
1.9.3
Stefan Hajnoczi
AppliedQuoted 7 lines · Chen Gang
When map '
netdev->rxs' fails, need free the original resource, or will cause resource leak.Signed-off-by Chen Gang <[email protected]>--- 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