diff options
author | wuchi <wuchi.zero@gmail.com> | 2022-09-09 18:10:25 +0800 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2022-10-03 14:21:43 -0700 |
commit | 83d87a4ddb3b4a42bb73b314b3d1acc3965a689f (patch) | |
tree | 408c35f2e47ba087912851ed3238b354ac584902 /kernel/relay.c | |
parent | 7ec354baa2ad6dcf1b481a5a582293cec0eb2a67 (diff) |
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>
Diffstat (limited to 'kernel/relay.c')
-rw-r--r-- | kernel/relay.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/kernel/relay.c b/kernel/relay.c index 6a611e779e95..d7edc934c56d 100644 --- a/kernel/relay.c +++ b/kernel/relay.c @@ -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) { - const size_t pa_size = n_pages * sizeof(struct page *); - if (pa_size > PAGE_SIZE) - return vzalloc(pa_size); - return kzalloc(pa_size, GFP_KERNEL); + return kvcalloc(n_pages, sizeof(struct page *), GFP_KERNEL); } /* |