diff options
author | Kees Cook <keescook@chromium.org> | 2018-06-18 10:50:33 -0700 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2018-06-22 14:51:12 -0400 |
commit | 50a7d3ba7c9ac5e0b7e03fc7f420180989361dbf (patch) | |
tree | b0a0dd88307ba7fbaa780a7367754b3871299a13 /drivers/md | |
parent | 7ccdbf85d3b2237cdbdafe6a47673dbdfab4b7a2 (diff) | |
download | op-kernel-dev-50a7d3ba7c9ac5e0b7e03fc7f420180989361dbf.zip op-kernel-dev-50a7d3ba7c9ac5e0b7e03fc7f420180989361dbf.tar.gz |
dm writecache: use 2-factor allocator arguments
This adjusts the allocator calls to use the 2-factor argument style, as
already done treewide for better defense against allocator overflows.
Signed-off-by: Kees Cook <keescook@chromium.org>
[snitzer: tweaked code to leave assignment in a test alone]
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/dm-writecache.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index 5961c77..07ea6a4 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -259,7 +259,7 @@ static int persistent_memory_claim(struct dm_writecache *wc) if (da != p) { long i; wc->memory_map = NULL; - pages = kvmalloc(p * sizeof(struct page *), GFP_KERNEL); + pages = kvmalloc_array(p, sizeof(struct page *), GFP_KERNEL); if (!pages) { r = -ENOMEM; goto err2; @@ -859,7 +859,7 @@ static int writecache_alloc_entries(struct dm_writecache *wc) if (wc->entries) return 0; - wc->entries = vmalloc(sizeof(struct wc_entry) * wc->n_blocks); + wc->entries = vmalloc(array_size(sizeof(struct wc_entry), wc->n_blocks)); if (!wc->entries) return -ENOMEM; for (b = 0; b < wc->n_blocks; b++) { @@ -1481,9 +1481,9 @@ static void __writecache_writeback_pmem(struct dm_writecache *wc, struct writeba wb->bio.bi_iter.bi_sector = read_original_sector(wc, e); wb->page_offset = PAGE_SIZE; if (max_pages <= WB_LIST_INLINE || - unlikely(!(wb->wc_list = kmalloc(max_pages * sizeof(struct wc_entry *), - GFP_NOIO | __GFP_NORETRY | - __GFP_NOMEMALLOC | __GFP_NOWARN)))) { + unlikely(!(wb->wc_list = kmalloc_array(max_pages, sizeof(struct wc_entry *), + GFP_NOIO | __GFP_NORETRY | + __GFP_NOMEMALLOC | __GFP_NOWARN)))) { wb->wc_list = wb->wc_list_inline; max_pages = WB_LIST_INLINE; } |