]> git.baikalelectronics.ru Git - kernel.git/commit
hwmon: (core) Do not use device managed functions for memory allocations
authorGuenter Roeck <linux@roeck-us.net>
Thu, 16 Jan 2020 18:44:17 +0000 (10:44 -0800)
committerGuenter Roeck <linux@roeck-us.net>
Fri, 17 Jan 2020 15:57:16 +0000 (07:57 -0800)
commit112858c1b0c8c7de5e1666a1aa1ed3372cb1f67b
treef14e6cb79fb5b97a5a0f88d247e03ed9f4c1a496
parenta08f579b9819b47cf8b137ffc9a48e4a6f38d267
hwmon: (core) Do not use device managed functions for memory allocations

The hwmon core uses device managed functions, tied to the hwmon parent
device, for various internal memory allocations. This is problematic
since hwmon device lifetime does not necessarily match its parent's
device lifetime. If there is a mismatch, memory leaks will accumulate
until the parent device is released.

Fix the problem by managing all memory allocations internally. The only
exception is memory allocation for thermal device registration, which
can be tied to the hwmon device, along with thermal device registration
itself.

Fixes: e510706c6f37 ("hwmon: (core) New hwmon registration API")
Cc: stable@vger.kernel.org # v4.14.x: 3ccb12d4b4e8: hwmon: Deal with errors from the thermal subsystem
Cc: stable@vger.kernel.org # v4.14.x: 6ce8a4aa87c3: hwmon: (core) Fix double-free in __hwmon_device_register()
Cc: stable@vger.kernel.org # v4.9.x: acd1010bcfcb: hwmon: (core) Simplify sysfs attribute name allocation
Cc: stable@vger.kernel.org # v4.9.x: 3ccb12d4b4e8: hwmon: Deal with errors from the thermal subsystem
Cc: stable@vger.kernel.org # v4.9.x: 6ce8a4aa87c3: hwmon: (core) Fix double-free in __hwmon_device_register()
Cc: stable@vger.kernel.org # v4.9+
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/hwmon.c