diff options
Diffstat (limited to 'drivers/extcon/extcon.c')
-rw-r--r-- | drivers/extcon/extcon.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 8bff5fd18185..af83ad58819c 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c | |||
@@ -1126,8 +1126,9 @@ int extcon_dev_register(struct extcon_dev *edev) | |||
1126 | char *str; | 1126 | char *str; |
1127 | struct extcon_cable *cable; | 1127 | struct extcon_cable *cable; |
1128 | 1128 | ||
1129 | edev->cables = kzalloc(sizeof(struct extcon_cable) * | 1129 | edev->cables = kcalloc(edev->max_supported, |
1130 | edev->max_supported, GFP_KERNEL); | 1130 | sizeof(struct extcon_cable), |
1131 | GFP_KERNEL); | ||
1131 | if (!edev->cables) { | 1132 | if (!edev->cables) { |
1132 | ret = -ENOMEM; | 1133 | ret = -ENOMEM; |
1133 | goto err_sysfs_alloc; | 1134 | goto err_sysfs_alloc; |
@@ -1136,7 +1137,7 @@ int extcon_dev_register(struct extcon_dev *edev) | |||
1136 | cable = &edev->cables[index]; | 1137 | cable = &edev->cables[index]; |
1137 | 1138 | ||
1138 | snprintf(buf, 10, "cable.%d", index); | 1139 | snprintf(buf, 10, "cable.%d", index); |
1139 | str = kzalloc(sizeof(char) * (strlen(buf) + 1), | 1140 | str = kzalloc(strlen(buf) + 1, |
1140 | GFP_KERNEL); | 1141 | GFP_KERNEL); |
1141 | if (!str) { | 1142 | if (!str) { |
1142 | for (index--; index >= 0; index--) { | 1143 | for (index--; index >= 0; index--) { |
@@ -1177,15 +1178,17 @@ int extcon_dev_register(struct extcon_dev *edev) | |||
1177 | for (index = 0; edev->mutually_exclusive[index]; index++) | 1178 | for (index = 0; edev->mutually_exclusive[index]; index++) |
1178 | ; | 1179 | ; |
1179 | 1180 | ||
1180 | edev->attrs_muex = kzalloc(sizeof(struct attribute *) * | 1181 | edev->attrs_muex = kcalloc(index + 1, |
1181 | (index + 1), GFP_KERNEL); | 1182 | sizeof(struct attribute *), |
1183 | GFP_KERNEL); | ||
1182 | if (!edev->attrs_muex) { | 1184 | if (!edev->attrs_muex) { |
1183 | ret = -ENOMEM; | 1185 | ret = -ENOMEM; |
1184 | goto err_muex; | 1186 | goto err_muex; |
1185 | } | 1187 | } |
1186 | 1188 | ||
1187 | edev->d_attrs_muex = kzalloc(sizeof(struct device_attribute) * | 1189 | edev->d_attrs_muex = kcalloc(index, |
1188 | index, GFP_KERNEL); | 1190 | sizeof(struct device_attribute), |
1191 | GFP_KERNEL); | ||
1189 | if (!edev->d_attrs_muex) { | 1192 | if (!edev->d_attrs_muex) { |
1190 | ret = -ENOMEM; | 1193 | ret = -ENOMEM; |
1191 | kfree(edev->attrs_muex); | 1194 | kfree(edev->attrs_muex); |
@@ -1194,7 +1197,7 @@ int extcon_dev_register(struct extcon_dev *edev) | |||
1194 | 1197 | ||
1195 | for (index = 0; edev->mutually_exclusive[index]; index++) { | 1198 | for (index = 0; edev->mutually_exclusive[index]; index++) { |
1196 | sprintf(buf, "0x%x", edev->mutually_exclusive[index]); | 1199 | sprintf(buf, "0x%x", edev->mutually_exclusive[index]); |
1197 | name = kzalloc(sizeof(char) * (strlen(buf) + 1), | 1200 | name = kzalloc(strlen(buf) + 1, |
1198 | GFP_KERNEL); | 1201 | GFP_KERNEL); |
1199 | if (!name) { | 1202 | if (!name) { |
1200 | for (index--; index >= 0; index--) { | 1203 | for (index--; index >= 0; index--) { |
@@ -1220,8 +1223,9 @@ int extcon_dev_register(struct extcon_dev *edev) | |||
1220 | 1223 | ||
1221 | if (edev->max_supported) { | 1224 | if (edev->max_supported) { |
1222 | edev->extcon_dev_type.groups = | 1225 | edev->extcon_dev_type.groups = |
1223 | kzalloc(sizeof(struct attribute_group *) * | 1226 | kcalloc(edev->max_supported + 2, |
1224 | (edev->max_supported + 2), GFP_KERNEL); | 1227 | sizeof(struct attribute_group *), |
1228 | GFP_KERNEL); | ||
1225 | if (!edev->extcon_dev_type.groups) { | 1229 | if (!edev->extcon_dev_type.groups) { |
1226 | ret = -ENOMEM; | 1230 | ret = -ENOMEM; |
1227 | goto err_alloc_groups; | 1231 | goto err_alloc_groups; |