]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
cpufreq: Use struct kobj_attribute instead of struct global_attr
authorViresh Kumar <viresh.kumar@linaro.org>
Fri, 25 Jan 2019 07:23:07 +0000 (12:53 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Mar 2019 21:03:06 +0000 (14:03 -0700)
commit85cf5519050d151a77273171f2b2faf0ce5af8eb
tree10cb749ec642821bda77404699d29793d28a89d9
parent99403097be0cbe12042775d9ca3a66f2018adc3e
cpufreq: Use struct kobj_attribute instead of struct global_attr

commit 625c85a62cb7d3c79f6e16de3cfa972033658250 upstream.

The cpufreq_global_kobject is created using kobject_create_and_add()
helper, which assigns the kobj_type as dynamic_kobj_ktype and show/store
routines are set to kobj_attr_show() and kobj_attr_store().

These routines pass struct kobj_attribute as an argument to the
show/store callbacks. But all the cpufreq files created using the
cpufreq_global_kobject expect the argument to be of type struct
attribute. Things work fine currently as no one accesses the "attr"
argument. We may not see issues even if the argument is used, as struct
kobj_attribute has struct attribute as its first element and so they
will both get same address.

But this is logically incorrect and we should rather use struct
kobj_attribute instead of struct global_attr in the cpufreq core and
drivers and the show/store callbacks should take struct kobj_attribute
as argument instead.

This bug is caught using CFI CLANG builds in android kernel which
catches mismatch in function prototypes for such callbacks.

Reported-by: Donghee Han <dh.han@samsung.com>
Reported-by: Sangkyu Kim <skwith.kim@samsung.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/cpufreq/cpufreq.c
drivers/cpufreq/intel_pstate.c
include/linux/cpufreq.h