relay: use kvcalloc to alloc page array in relay_alloc_page_array
kvcalloc() is safer because it will check the integer overflows, and using it will simple the logic of allocation size. Link: https://lkml.kernel.org/r/20220909101025.82955-1-wuchi.zero@gmail.com Signed-off-by: wuchi <wuchi.zero@gmail.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Jens Axboe <axboe@kernel.dk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>pull/520/merge
parent
7ec354baa2
commit
83d87a4ddb
|
|
@ -60,10 +60,7 @@ static const struct vm_operations_struct relay_file_mmap_ops = {
|
||||||
*/
|
*/
|
||||||
static struct page **relay_alloc_page_array(unsigned int n_pages)
|
static struct page **relay_alloc_page_array(unsigned int n_pages)
|
||||||
{
|
{
|
||||||
const size_t pa_size = n_pages * sizeof(struct page *);
|
return kvcalloc(n_pages, sizeof(struct page *), GFP_KERNEL);
|
||||||
if (pa_size > PAGE_SIZE)
|
|
||||||
return vzalloc(pa_size);
|
|
||||||
return kzalloc(pa_size, GFP_KERNEL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue