s390/idal: use struct_size() in kmalloc()
Use the new struct_size() helper to keep code simple. Signed-off-by: xiaolinkui <xiaolinkui@kylinos.cn> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
This commit is contained in:
parent
a646ef398e
commit
31885a8dad
|
@ -122,8 +122,7 @@ idal_buffer_alloc(size_t size, int page_order)
|
||||||
|
|
||||||
nr_ptrs = (size + IDA_BLOCK_SIZE - 1) >> IDA_SIZE_LOG;
|
nr_ptrs = (size + IDA_BLOCK_SIZE - 1) >> IDA_SIZE_LOG;
|
||||||
nr_chunks = (4096 << page_order) >> IDA_SIZE_LOG;
|
nr_chunks = (4096 << page_order) >> IDA_SIZE_LOG;
|
||||||
ib = kmalloc(sizeof(struct idal_buffer) + nr_ptrs*sizeof(void *),
|
ib = kmalloc(struct_size(ib, data, nr_ptrs), GFP_DMA | GFP_KERNEL);
|
||||||
GFP_DMA | GFP_KERNEL);
|
|
||||||
if (ib == NULL)
|
if (ib == NULL)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
ib->size = size;
|
ib->size = size;
|
||||||
|
|
Loading…
Reference in New Issue