aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen/gntdev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/xen/gntdev.c')
-rw-r--r--drivers/xen/gntdev.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index 610bfc6be177..2e22df2f7a3f 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -105,6 +105,21 @@ static void gntdev_print_maps(struct gntdev_priv *priv,
105#endif 105#endif
106} 106}
107 107
108static void gntdev_free_map(struct grant_map *map)
109{
110 if (map == NULL)
111 return;
112
113 if (map->pages)
114 free_xenballooned_pages(map->count, map->pages);
115 kfree(map->pages);
116 kfree(map->grants);
117 kfree(map->map_ops);
118 kfree(map->unmap_ops);
119 kfree(map->kmap_ops);
120 kfree(map);
121}
122
108static struct grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count) 123static struct grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count)
109{ 124{
110 struct grant_map *add; 125 struct grant_map *add;
@@ -142,12 +157,7 @@ static struct grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count)
142 return add; 157 return add;
143 158
144err: 159err:
145 kfree(add->pages); 160 gntdev_free_map(add);
146 kfree(add->grants);
147 kfree(add->map_ops);
148 kfree(add->unmap_ops);
149 kfree(add->kmap_ops);
150 kfree(add);
151 return NULL; 161 return NULL;
152} 162}
153 163
@@ -198,17 +208,9 @@ static void gntdev_put_map(struct grant_map *map)
198 evtchn_put(map->notify.event); 208 evtchn_put(map->notify.event);
199 } 209 }
200 210
201 if (map->pages) { 211 if (map->pages && !use_ptemod)
202 if (!use_ptemod) 212 unmap_grant_pages(map, 0, map->count);
203 unmap_grant_pages(map, 0, map->count); 213 gntdev_free_map(map);
204
205 free_xenballooned_pages(map->count, map->pages);
206 }
207 kfree(map->pages);
208 kfree(map->grants);
209 kfree(map->map_ops);
210 kfree(map->unmap_ops);
211 kfree(map);
212} 214}
213 215
214/* ------------------------------------------------------------------ */ 216/* ------------------------------------------------------------------ */