hwmon: (acpi_power_meter) replace open-coded kmemdup_nul
[linux-2.6-microblaze.git] / drivers / hwmon / acpi_power_meter.c
index fa28d44..8db7402 100644 (file)
@@ -796,14 +796,13 @@ static int read_capabilities(struct acpi_power_meter_resource *resource)
                        goto error;
                }
 
-               *str = kcalloc(element->string.length + 1, sizeof(u8),
-                              GFP_KERNEL);
+               *str = kmemdup_nul(element->string.pointer, element->string.length,
+                                  GFP_KERNEL);
                if (!*str) {
                        res = -ENOMEM;
                        goto error;
                }
 
-               strncpy(*str, element->string.pointer, element->string.length);
                str++;
        }