提交 732e4c8d 编写于 作者: D durgadoss.r@intel.com 提交者: Zhang Rui

Thermal: Check for validity before doing kfree

The thermal_release function is called whenever
any device belonging to 'thermal' class unregisters.
This function performs kfree(cdev) without any check.
In cases where there are more device registrations
other than just 'thermal_zone' and 'cooling_device'
this might accidently free memory allocated them
silently; and cause memory errors.

This patch changes this behavior by doing
kfree(cdev) only when the device pointer belongs
to a real cdev i.e. cooling_device.
Signed-off-by: NDurgadoss R <durgadoss.r@intel.com>
Signed-off-by: NZhang Rui <rui.zhang@intel.com>
上级 a8227948
......@@ -1038,7 +1038,8 @@ static void thermal_release(struct device *dev)
sizeof("thermal_zone") - 1)) {
tz = to_thermal_zone(dev);
kfree(tz);
} else {
} else if(!strncmp(dev_name(dev), "cooling_device",
sizeof("cooling_device") - 1)){
cdev = to_cooling_device(dev);
kfree(cdev);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册