xen-netfront: fix netfront create_dev error path
The failure path for allocating rx grant refs should not try to free tx grant refs because tx grant refs were allocated after that. Also fix the error path for xen_net_read_mac. Submitted by: Wei Liu <wei.liu2@citrix.com> Reviewed by: royger Differential Revision: https://reviews.freebsd.org/D3891 Sponsored by: Citrix Systems R&D
This commit is contained in:
parent
49a8398485
commit
6f8aa66030
@ -1885,7 +1885,7 @@ create_netdev(device_t dev)
|
||||
&np->gref_tx_head) != 0) {
|
||||
IPRINTK("#### netfront can't alloc tx grant refs\n");
|
||||
err = ENOMEM;
|
||||
goto exit;
|
||||
goto error;
|
||||
}
|
||||
/* A grant for every rx ring slot */
|
||||
if (gnttab_alloc_grant_references(RX_MAX_TARGET,
|
||||
@ -1893,12 +1893,15 @@ create_netdev(device_t dev)
|
||||
WPRINTK("#### netfront can't alloc rx grant refs\n");
|
||||
gnttab_free_grant_references(np->gref_tx_head);
|
||||
err = ENOMEM;
|
||||
goto exit;
|
||||
goto error;
|
||||
}
|
||||
|
||||
err = xen_net_read_mac(dev, np->mac);
|
||||
if (err)
|
||||
goto out;
|
||||
if (err) {
|
||||
gnttab_free_grant_references(np->gref_rx_head);
|
||||
gnttab_free_grant_references(np->gref_tx_head);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Set up ifnet structure */
|
||||
ifp = np->xn_ifp = if_alloc(IFT_ETHER);
|
||||
@ -1925,9 +1928,8 @@ create_netdev(device_t dev)
|
||||
|
||||
return (0);
|
||||
|
||||
exit:
|
||||
gnttab_free_grant_references(np->gref_tx_head);
|
||||
out:
|
||||
error:
|
||||
KASSERT(err != 0, ("Error path with no error code specified"));
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user