regulator: vctrl: Fix out of bounds array access for vctrl->vtable
commita9bbb453b50c91295ab362e4832eb37fd4e6785d
authorAxel Lin <axel.lin@ingics.com>
Fri, 14 Apr 2017 02:50:43 +0000 (14 10:50 +0800)
committerMark Brown <broonie@kernel.org>
Fri, 14 Apr 2017 17:01:03 +0000 (14 18:01 +0100)
treecf548ad6e42a431228f1d360905ef3ad852db6da
parent9dee7a72d0c7cdfa2573c48b1e5f928c721d54d5
regulator: vctrl: Fix out of bounds array access for vctrl->vtable

Current code only allocates rdesc->n_voltages entries for vctrl->vtable.
Thus use rdesc->n_voltages instead of n_voltages in the for loop.

While at it, also switch to use devm_kcalloc instead of devm_kmalloc_array
+ __GFP_ZERO flag and fix the argument order.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/vctrl-regulator.c