diff options
Diffstat (limited to 'drivers/hwmon/pmbus/pmbus_core.c')
-rw-r--r-- | drivers/hwmon/pmbus/pmbus_core.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 80eef50c50fd..9add60920ac0 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c | |||
@@ -766,12 +766,14 @@ static ssize_t pmbus_show_label(struct device *dev, | |||
766 | static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr) | 766 | static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr) |
767 | { | 767 | { |
768 | if (data->num_attributes >= data->max_attributes - 1) { | 768 | if (data->num_attributes >= data->max_attributes - 1) { |
769 | data->max_attributes += PMBUS_ATTR_ALLOC_SIZE; | 769 | int new_max_attrs = data->max_attributes + PMBUS_ATTR_ALLOC_SIZE; |
770 | data->group.attrs = krealloc(data->group.attrs, | 770 | void *new_attrs = krealloc(data->group.attrs, |
771 | sizeof(struct attribute *) * | 771 | new_max_attrs * sizeof(void *), |
772 | data->max_attributes, GFP_KERNEL); | 772 | GFP_KERNEL); |
773 | if (data->group.attrs == NULL) | 773 | if (!new_attrs) |
774 | return -ENOMEM; | 774 | return -ENOMEM; |
775 | data->group.attrs = new_attrs; | ||
776 | data->max_attributes = new_max_attrs; | ||
775 | } | 777 | } |
776 | 778 | ||
777 | data->group.attrs[data->num_attributes++] = attr; | 779 | data->group.attrs[data->num_attributes++] = attr; |