cpufreq: sfi: use kmemdup rather than duplicating its implementation
authorAndrzej Hajda <a.hajda@samsung.com>
Fri, 7 Aug 2015 07:59:17 +0000 (09:59 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 1 Sep 2015 13:51:15 +0000 (15:51 +0200)
The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/sfi-cpufreq.c

index ffa3389e535b828bc3794c65d32a3d805c219c2e..992ce6f9abecdacf256e9d61c16a9e0d6742b767 100644 (file)
@@ -45,12 +45,10 @@ static int sfi_parse_freq(struct sfi_table_header *table)
        pentry = (struct sfi_freq_table_entry *)sb->pentry;
        totallen = num_freq_table_entries * sizeof(*pentry);
 
-       sfi_cpufreq_array = kzalloc(totallen, GFP_KERNEL);
+       sfi_cpufreq_array = kmemdup(pentry, totallen, GFP_KERNEL);
        if (!sfi_cpufreq_array)
                return -ENOMEM;
 
-       memcpy(sfi_cpufreq_array, pentry, totallen);
-
        return 0;
 }