From: Asias He <asias@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
target-devel@vger.kernel.org
Subject: [PATCH 3/4] vhost-net: Free ubuf when vhost_dev_ioctl fails
Date: Fri, 3 May 2013 14:25:17 +0800 [thread overview]
Message-ID: <1367562318-11989-4-git-send-email-asias@redhat.com> (raw)
In-Reply-To: <1367562318-11989-1-git-send-email-asias@redhat.com>
Free ubuf when vhost_dev_ioctl for VHOST_SET_OWNER fails.
Signed-off-by: Asias He <asias@redhat.com>
---
drivers/vhost/net.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index b2f6b41..eb73217 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -152,6 +152,19 @@ void vhost_ubuf_put_and_wait(struct vhost_ubuf_ref *ubufs)
kfree(ubufs);
}
+static void vhost_net_clear_ubuf_info(struct vhost_net *n)
+{
+
+ bool zcopy;
+ int i;
+
+ for (i = 0; i < n->dev.nvqs; ++i) {
+ zcopy = vhost_zcopy_mask & (0x1 << i);
+ if (zcopy)
+ kfree(n->vqs[i].ubuf_info);
+ }
+}
+
int vhost_net_set_ubuf_info(struct vhost_net *n)
{
bool zcopy;
@@ -1069,10 +1082,13 @@ static long vhost_net_ioctl(struct file *f, unsigned int ioctl,
goto out;
}
r = vhost_dev_ioctl(&n->dev, ioctl, argp);
- if (r == -ENOIOCTLCMD)
+ if (r == -ENOIOCTLCMD) {
r = vhost_vring_ioctl(&n->dev, ioctl, argp);
- else
+ } else {
+ if (r < 0 && ioctl == VHOST_SET_OWNER)
+ vhost_net_clear_ubuf_info(n);
vhost_net_flush(n);
+ }
out:
mutex_unlock(&n->dev.mutex);
return r;
--
1.8.1.4
next prev parent reply other threads:[~2013-05-03 6:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-03 6:25 [PATCH 0/4] vhost and vhost-net cleanups Asias He
2013-05-03 6:25 ` [PATCH 1/4] vhost: Remove comments for hdr in vhost.h Asias He
2013-05-03 6:25 ` [PATCH 2/4] vhost: Simplify dev->vqs[i] access Asias He
2013-05-03 6:25 ` Asias He [this message]
2013-05-05 13:50 ` [PATCH 3/4] vhost-net: Free ubuf when vhost_dev_ioctl fails Michael S. Tsirkin
2013-05-06 3:17 ` Asias He
2013-05-03 6:25 ` [PATCH 4/4] vhost-net: Cleanup vhost_ubuf adn vhost_zcopy Asias He
[not found] ` <1367562318-11989-5-git-send-email-asias@redhat.com>
2013-05-06 8:17 ` Michael S. Tsirkin
2013-05-06 8:25 ` Asias He
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1367562318-11989-4-git-send-email-asias@redhat.com \
--to=asias@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--cc=target-devel@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox