hwmon: pmbus: Use devm_krealloc_array

Now that it exists, use it instead of doing the multiplication manually.

Acked-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: James Clark <james.clark@arm.com>
Link: https://lore.kernel.org/r/20230509094942.396150-3-james.clark@arm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
James Clark 2023-05-09 10:49:39 +01:00 committed by Greg Kroah-Hartman
parent d388f06ace
commit c5f7548445
1 changed files with 3 additions and 3 deletions

View File

@ -1191,9 +1191,9 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
{
if (data->num_attributes >= data->max_attributes - 1) {
int new_max_attrs = data->max_attributes + PMBUS_ATTR_ALLOC_SIZE;
void *new_attrs = devm_krealloc(data->dev, data->group.attrs,
new_max_attrs * sizeof(void *),
GFP_KERNEL);
void *new_attrs = devm_krealloc_array(data->dev, data->group.attrs,
new_max_attrs, sizeof(void *),
GFP_KERNEL);
if (!new_attrs)
return -ENOMEM;
data->group.attrs = new_attrs;