summaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
authorEduardo Valentin <edubezval@gmail.com>2016-11-07 21:09:25 -0800
committerZhang Rui <rui.zhang@intel.com>2016-11-23 10:06:12 +0800
commit95e3ed1513494aa2d0aaba7a99fb7aa8b51dcfc8 (patch)
tree15319f30bef7d11b39b0d2c5f657cd505149d499 /drivers/thermal
parent38e7b549af829ad2abd94b60e555227a15f9ecff (diff)
downloadlinux-stable-95e3ed1513494aa2d0aaba7a99fb7aa8b51dcfc8.tar.gz
linux-stable-95e3ed1513494aa2d0aaba7a99fb7aa8b51dcfc8.tar.bz2
linux-stable-95e3ed1513494aa2d0aaba7a99fb7aa8b51dcfc8.zip
thermal: core: use kzalloc(sizeof(*ptr),...)
As a safety check, this patch changes thermal core to check for pointer content size, instead of type size, while allocating memory. Cc: Zhang Rui <rui.zhang@intel.com> Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin <edubezval@gmail.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/thermal_core.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 2db21e53d0d0..4f9384482818 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -674,8 +674,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
if (lower > upper || upper > max_state)
return -EINVAL;
- dev =
- kzalloc(sizeof(struct thermal_instance), GFP_KERNEL);
+ dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev)
return -ENOMEM;
dev->tz = tz;
@@ -917,7 +916,7 @@ __thermal_cooling_device_register(struct device_node *np,
!ops->set_cur_state)
return ERR_PTR(-EINVAL);
- cdev = kzalloc(sizeof(struct thermal_cooling_device), GFP_KERNEL);
+ cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
if (!cdev)
return ERR_PTR(-ENOMEM);
@@ -1163,7 +1162,7 @@ thermal_zone_device_register(const char *type, int trips, int mask,
if (trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp))
return ERR_PTR(-EINVAL);
- tz = kzalloc(sizeof(struct thermal_zone_device), GFP_KERNEL);
+ tz = kzalloc(sizeof(*tz), GFP_KERNEL);
if (!tz)
return ERR_PTR(-ENOMEM);