]> git.baikalelectronics.ru Git - kernel.git/commit
thermal: sysfs: Fix cooling_device_stats_setup() error code path
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 29 Jul 2022 15:39:07 +0000 (17:39 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 3 Aug 2022 17:14:26 +0000 (19:14 +0200)
commit24ae2c495608de6b9022bf8951b76fee1e1c9ce4
treee719df9b5e7808c00858063f606cadc19360fec4
parentcebe436cccaf34b7b321c7bdcc9a7463f3fb44b6
thermal: sysfs: Fix cooling_device_stats_setup() error code path

If cooling_device_stats_setup() fails to create the stats object, it
must clear the last slot in cooling_device_attr_groups that was
initially empty (so as to make it possible to add stats attributes to
the cooling device attribute groups).

Failing to do so may cause the stats attributes to be created by
mistake for a device that doesn't have a stats object, because the
slot in question might be populated previously during the registration
of another cooling device.

Fixes: 9db8901ea0af ("thermal: Add cooling device's statistics in sysfs")
Reported-by: Di Shen <di.shen@unisoc.com>
Tested-by: Di Shen <di.shen@unisoc.com>
Cc: 4.17+ <stable@vger.kernel.org> # 4.17+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/thermal_sysfs.c