powercap/drivers/dtpm: Fix size of object being allocated
authorColin Ian King <colin.king@canonical.com>
Mon, 4 Jan 2021 12:10:53 +0000 (12:10 +0000)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 7 Jan 2021 17:16:03 +0000 (18:16 +0100)
The kzalloc allocation for dtpm_cpu is currently allocating the size
of the pointer and not the size of the structure. Fix this by using
the correct sizeof argument.

Addresses-Coverity: ("Wrong sizeof argument")
Fixes: 0e8f68d7f048 ("powercap/drivers/dtpm: Add CPU energy model based support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/powercap/dtpm_cpu.c

index 6933c78..51c3669 100644 (file)
@@ -200,7 +200,7 @@ static int cpuhp_dtpm_cpu_online(unsigned int cpu)
        if (!dtpm)
                return -EINVAL;
 
-       dtpm_cpu = kzalloc(sizeof(dtpm_cpu), GFP_KERNEL);
+       dtpm_cpu = kzalloc(sizeof(*dtpm_cpu), GFP_KERNEL);
        if (!dtpm_cpu)
                goto out_kfree_dtpm;