Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

reset: sti: Use devm_kcalloc() in syscfg_reset_controller_register()

* A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "devm_kcalloc".

* Replace the specification of a data structure by a pointer dereference
to make the corresponding size determination a bit safer according to
the Linux coding style convention.

* Delete the local variable "size" which became unnecessary with
this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

authored by

Markus Elfring and committed by
Philipp Zabel
aa248927 2ea659a9

+2 -4
+2 -4
drivers/reset/sti/reset-syscfg.c
··· 145 145 const struct syscfg_reset_controller_data *data) 146 146 { 147 147 struct syscfg_reset_controller *rc; 148 - size_t size; 149 148 int i, err; 150 149 151 150 rc = devm_kzalloc(dev, sizeof(*rc), GFP_KERNEL); 152 151 if (!rc) 153 152 return -ENOMEM; 154 153 155 - size = sizeof(struct syscfg_reset_channel) * data->nr_channels; 156 - 157 - rc->channels = devm_kzalloc(dev, size, GFP_KERNEL); 154 + rc->channels = devm_kcalloc(dev, data->nr_channels, 155 + sizeof(*rc->channels), GFP_KERNEL); 158 156 if (!rc->channels) 159 157 return -ENOMEM; 160 158