Skip to content

Commit 0303e1b

Browse files
Chen Lialexdeucher
authored andcommitted
radeon: use kvcalloc for relocs and chunks
kvmalloc_array + __GFP_ZERO is the same with kvcalloc. As for p->chunks, it will be used in: ``` if (ib_chunk->kdata) memcpy(parser->ib.ptr, ib_chunk->kdata, ib_chunk->length_dw * 4); ``` If chunks doesn't zero out with __GFP_ZERO, it may point to somewhere else, e.g., ``` Unable to handle kernel paging request at virtual address 0000000000010000 ... pc is at memcpy+0x84/0x250 ra is at radeon_cs_ioctl+0x368/0xb90 [radeon] ``` after allocating chunks with __GFP_KERNEL/kvcalloc, this bug is fixed. Fixes: 3fcb4f0 ("drm/radeon: Use kvmalloc for CS chunks") Reviewed-by: Christian König <[email protected]> Signed-off-by: Chen Li <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 2d28b70 commit 0303e1b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/gpu/drm/radeon/radeon_cs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p)
9393
p->dma_reloc_idx = 0;
9494
/* FIXME: we assume that each relocs use 4 dwords */
9595
p->nrelocs = chunk->length_dw / 4;
96-
p->relocs = kvmalloc_array(p->nrelocs, sizeof(struct radeon_bo_list),
97-
GFP_KERNEL | __GFP_ZERO);
96+
p->relocs = kvcalloc(p->nrelocs, sizeof(struct radeon_bo_list),
97+
GFP_KERNEL);
9898
if (p->relocs == NULL) {
9999
return -ENOMEM;
100100
}
@@ -299,7 +299,7 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
299299
}
300300
p->cs_flags = 0;
301301
p->nchunks = cs->num_chunks;
302-
p->chunks = kvmalloc_array(p->nchunks, sizeof(struct radeon_cs_chunk), GFP_KERNEL);
302+
p->chunks = kvcalloc(p->nchunks, sizeof(struct radeon_cs_chunk), GFP_KERNEL);
303303
if (p->chunks == NULL) {
304304
return -ENOMEM;
305305
}

0 commit comments

Comments
 (0)