diff options
author | Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com> | 2019-02-14 09:23:21 -0500 |
---|---|---|
committer | Juergen Gross <jgross@suse.com> | 2019-02-18 00:50:10 -0500 |
commit | 068e79f4a9d613f4327cb4062a1e49c0eaca7149 (patch) | |
tree | 8c58b3e65adf69dbf417218000fd3d71d46bf528 | |
parent | fa13e665e02874c0a5f4d06d6967ae34a6cb3d6a (diff) |
xen/gntdev: Check and release imported dma-bufs on close
Check if there are any imported dma-bufs left not released by
user-space when grant device's release callback is called and
free those if this is the case. This can happen if user-space
leaks the buffers because of a bug or application has been
terminated for any reason.
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Reviewed-by: Boris Ostrovsky@oracle.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
-rw-r--r-- | drivers/xen/gntdev-dmabuf.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/xen/gntdev-dmabuf.c b/drivers/xen/gntdev-dmabuf.c index d97fcfc5e558..2c4f324f8626 100644 --- a/drivers/xen/gntdev-dmabuf.c +++ b/drivers/xen/gntdev-dmabuf.c | |||
@@ -745,6 +745,14 @@ static int dmabuf_imp_release(struct gntdev_dmabuf_priv *priv, u32 fd) | |||
745 | return 0; | 745 | return 0; |
746 | } | 746 | } |
747 | 747 | ||
748 | static void dmabuf_imp_release_all(struct gntdev_dmabuf_priv *priv) | ||
749 | { | ||
750 | struct gntdev_dmabuf *q, *gntdev_dmabuf; | ||
751 | |||
752 | list_for_each_entry_safe(gntdev_dmabuf, q, &priv->imp_list, next) | ||
753 | dmabuf_imp_release(priv, gntdev_dmabuf->fd); | ||
754 | } | ||
755 | |||
748 | /* DMA buffer IOCTL support. */ | 756 | /* DMA buffer IOCTL support. */ |
749 | 757 | ||
750 | long gntdev_ioctl_dmabuf_exp_from_refs(struct gntdev_priv *priv, int use_ptemod, | 758 | long gntdev_ioctl_dmabuf_exp_from_refs(struct gntdev_priv *priv, int use_ptemod, |
@@ -862,5 +870,6 @@ struct gntdev_dmabuf_priv *gntdev_dmabuf_init(struct file *filp) | |||
862 | 870 | ||
863 | void gntdev_dmabuf_fini(struct gntdev_dmabuf_priv *priv) | 871 | void gntdev_dmabuf_fini(struct gntdev_dmabuf_priv *priv) |
864 | { | 872 | { |
873 | dmabuf_imp_release_all(priv); | ||
865 | kfree(priv); | 874 | kfree(priv); |
866 | } | 875 | } |