Commit cc513332 authored by Brian Kocoloski's avatar Brian Kocoloski

bugfix: only destroy xrbuf if it is created successfully

parent 3f4fc19a
......@@ -52,6 +52,7 @@ struct palacios_eth_device {
struct v3_guest * guest;
struct file * anon_filp;
int connected;
int xrbuf_created;
waitq_t intr_queue;
struct mutex mutex;
......@@ -120,9 +121,11 @@ eth_last_put(struct kref * kref)
struct palacios_eth_device * eth = container_of(kref, struct palacios_eth_device, refcount);
int status;
status = xrbuf_destroy(eth->xrbuf_rx);
if (status != 0)
ERROR("Failed to destroy xrbuf\n");
if (eth->xrbuf_created) {
status = xrbuf_destroy(eth->xrbuf_rx);
if (status != 0)
ERROR("Failed to destroy xrbuf\n");
}
v3_lwk_printk("Eth dev %s torn down\n", eth->dev_name);
kmem_free(eth);
......@@ -487,6 +490,7 @@ tap_connect(struct v3_guest * guest,
}
eth->connected = 1;
eth->xrbuf_created = 1;
eth->guest = guest;
vm_get(eth->guest);
eth_get(eth); /* hold an extra reference to protect userspace */
......@@ -502,9 +506,8 @@ out_copy:
out_kfs:
out_xrbuf_segid:
if (status != 0) {
if (status != 0)
(void)xrbuf_destroy(eth->xrbuf_rx);
}
out_xrbuf:
out_already:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment