Skip to content

Commit b3f7931

Browse files
committed
xen/gntdev: switch from kcalloc() to kvcalloc()
With sufficient many pages to map gntdev can reach order 9 allocation sizes. As there is no need to have physically contiguous buffers switch to kvcalloc() in order to avoid failing allocations. Signed-off-by: Juergen Gross <[email protected]> Reviewed-by: Oleksandr Andrushchenko <[email protected]> Reviewed-by: Boris Ostrovsky <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent 3b06ac6 commit b3f7931

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

drivers/xen/gntdev.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,14 @@ static void gntdev_free_map(struct gntdev_grant_map *map)
112112
gnttab_free_pages(map->count, map->pages);
113113

114114
#ifdef CONFIG_XEN_GRANT_DMA_ALLOC
115-
kfree(map->frames);
115+
kvfree(map->frames);
116116
#endif
117-
kfree(map->pages);
118-
kfree(map->grants);
119-
kfree(map->map_ops);
120-
kfree(map->unmap_ops);
121-
kfree(map->kmap_ops);
122-
kfree(map->kunmap_ops);
117+
kvfree(map->pages);
118+
kvfree(map->grants);
119+
kvfree(map->map_ops);
120+
kvfree(map->unmap_ops);
121+
kvfree(map->kmap_ops);
122+
kvfree(map->kunmap_ops);
123123
kfree(map);
124124
}
125125

@@ -133,12 +133,13 @@ struct gntdev_grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count,
133133
if (NULL == add)
134134
return NULL;
135135

136-
add->grants = kcalloc(count, sizeof(add->grants[0]), GFP_KERNEL);
137-
add->map_ops = kcalloc(count, sizeof(add->map_ops[0]), GFP_KERNEL);
138-
add->unmap_ops = kcalloc(count, sizeof(add->unmap_ops[0]), GFP_KERNEL);
139-
add->kmap_ops = kcalloc(count, sizeof(add->kmap_ops[0]), GFP_KERNEL);
140-
add->kunmap_ops = kcalloc(count, sizeof(add->kunmap_ops[0]), GFP_KERNEL);
141-
add->pages = kcalloc(count, sizeof(add->pages[0]), GFP_KERNEL);
136+
add->grants = kvcalloc(count, sizeof(add->grants[0]), GFP_KERNEL);
137+
add->map_ops = kvcalloc(count, sizeof(add->map_ops[0]), GFP_KERNEL);
138+
add->unmap_ops = kvcalloc(count, sizeof(add->unmap_ops[0]), GFP_KERNEL);
139+
add->kmap_ops = kvcalloc(count, sizeof(add->kmap_ops[0]), GFP_KERNEL);
140+
add->kunmap_ops = kvcalloc(count,
141+
sizeof(add->kunmap_ops[0]), GFP_KERNEL);
142+
add->pages = kvcalloc(count, sizeof(add->pages[0]), GFP_KERNEL);
142143
if (NULL == add->grants ||
143144
NULL == add->map_ops ||
144145
NULL == add->unmap_ops ||
@@ -157,8 +158,8 @@ struct gntdev_grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count,
157158
if (dma_flags & (GNTDEV_DMA_FLAG_WC | GNTDEV_DMA_FLAG_COHERENT)) {
158159
struct gnttab_dma_alloc_args args;
159160

160-
add->frames = kcalloc(count, sizeof(add->frames[0]),
161-
GFP_KERNEL);
161+
add->frames = kvcalloc(count, sizeof(add->frames[0]),
162+
GFP_KERNEL);
162163
if (!add->frames)
163164
goto err;
164165

0 commit comments

Comments
 (0)