diff options
Diffstat (limited to 'lib/test_rhashtable.c')
-rw-r--r-- | lib/test_rhashtable.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c index f4000c137dbe..fb6968109113 100644 --- a/lib/test_rhashtable.c +++ b/lib/test_rhashtable.c | |||
@@ -285,12 +285,14 @@ static int __init test_rhltable(unsigned int entries) | |||
285 | if (entries == 0) | 285 | if (entries == 0) |
286 | entries = 1; | 286 | entries = 1; |
287 | 287 | ||
288 | rhl_test_objects = vzalloc(sizeof(*rhl_test_objects) * entries); | 288 | rhl_test_objects = vzalloc(array_size(entries, |
289 | sizeof(*rhl_test_objects))); | ||
289 | if (!rhl_test_objects) | 290 | if (!rhl_test_objects) |
290 | return -ENOMEM; | 291 | return -ENOMEM; |
291 | 292 | ||
292 | ret = -ENOMEM; | 293 | ret = -ENOMEM; |
293 | obj_in_table = vzalloc(BITS_TO_LONGS(entries) * sizeof(unsigned long)); | 294 | obj_in_table = vzalloc(array_size(sizeof(unsigned long), |
295 | BITS_TO_LONGS(entries))); | ||
294 | if (!obj_in_table) | 296 | if (!obj_in_table) |
295 | goto out_free; | 297 | goto out_free; |
296 | 298 | ||
@@ -706,7 +708,8 @@ static int __init test_rht_init(void) | |||
706 | test_rht_params.max_size = max_size ? : roundup_pow_of_two(entries); | 708 | test_rht_params.max_size = max_size ? : roundup_pow_of_two(entries); |
707 | test_rht_params.nelem_hint = size; | 709 | test_rht_params.nelem_hint = size; |
708 | 710 | ||
709 | objs = vzalloc((test_rht_params.max_size + 1) * sizeof(struct test_obj)); | 711 | objs = vzalloc(array_size(sizeof(struct test_obj), |
712 | test_rht_params.max_size + 1)); | ||
710 | if (!objs) | 713 | if (!objs) |
711 | return -ENOMEM; | 714 | return -ENOMEM; |
712 | 715 | ||
@@ -753,10 +756,10 @@ static int __init test_rht_init(void) | |||
753 | pr_info("Testing concurrent rhashtable access from %d threads\n", | 756 | pr_info("Testing concurrent rhashtable access from %d threads\n", |
754 | tcount); | 757 | tcount); |
755 | sema_init(&prestart_sem, 1 - tcount); | 758 | sema_init(&prestart_sem, 1 - tcount); |
756 | tdata = vzalloc(tcount * sizeof(struct thread_data)); | 759 | tdata = vzalloc(array_size(tcount, sizeof(struct thread_data))); |
757 | if (!tdata) | 760 | if (!tdata) |
758 | return -ENOMEM; | 761 | return -ENOMEM; |
759 | objs = vzalloc(tcount * entries * sizeof(struct test_obj)); | 762 | objs = vzalloc(array3_size(sizeof(struct test_obj), tcount, entries)); |
760 | if (!objs) { | 763 | if (!objs) { |
761 | vfree(tdata); | 764 | vfree(tdata); |
762 | return -ENOMEM; | 765 | return -ENOMEM; |