diff options
author | Eduardo Valentin <edubezval@gmail.com> | 2016-11-08 00:09:25 -0500 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2016-11-22 21:06:12 -0500 |
commit | 95e3ed1513494aa2d0aaba7a99fb7aa8b51dcfc8 (patch) | |
tree | 15319f30bef7d11b39b0d2c5f657cd505149d499 /drivers/thermal | |
parent | 38e7b549af829ad2abd94b60e555227a15f9ecff (diff) |
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.c | 7 |
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, | |||
674 | if (lower > upper || upper > max_state) | 674 | if (lower > upper || upper > max_state) |
675 | return -EINVAL; | 675 | return -EINVAL; |
676 | 676 | ||
677 | dev = | 677 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
678 | kzalloc(sizeof(struct thermal_instance), GFP_KERNEL); | ||
679 | if (!dev) | 678 | if (!dev) |
680 | return -ENOMEM; | 679 | return -ENOMEM; |
681 | dev->tz = tz; | 680 | dev->tz = tz; |
@@ -917,7 +916,7 @@ __thermal_cooling_device_register(struct device_node *np, | |||
917 | !ops->set_cur_state) | 916 | !ops->set_cur_state) |
918 | return ERR_PTR(-EINVAL); | 917 | return ERR_PTR(-EINVAL); |
919 | 918 | ||
920 | cdev = kzalloc(sizeof(struct thermal_cooling_device), GFP_KERNEL); | 919 | cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); |
921 | if (!cdev) | 920 | if (!cdev) |
922 | return ERR_PTR(-ENOMEM); | 921 | return ERR_PTR(-ENOMEM); |
923 | 922 | ||
@@ -1163,7 +1162,7 @@ thermal_zone_device_register(const char *type, int trips, int mask, | |||
1163 | if (trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp)) | 1162 | if (trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp)) |
1164 | return ERR_PTR(-EINVAL); | 1163 | return ERR_PTR(-EINVAL); |
1165 | 1164 | ||
1166 | tz = kzalloc(sizeof(struct thermal_zone_device), GFP_KERNEL); | 1165 | tz = kzalloc(sizeof(*tz), GFP_KERNEL); |
1167 | if (!tz) | 1166 | if (!tz) |
1168 | return ERR_PTR(-ENOMEM); | 1167 | return ERR_PTR(-ENOMEM); |
1169 | 1168 | ||