aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/intel_ips.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2010-06-21 11:40:15 -0400
committerMatthew Garrett <mjg@redhat.com>2010-08-03 09:48:48 -0400
commite9ec7f3539cbeae8ffc5d7b30543e5612df5cba3 (patch)
tree426f193628cf83689c11dc7a4e8d5afd805a9421 /drivers/platform/x86/intel_ips.c
parentdfec5c48cdfdcb08d73d24cbf277de543ef864ae (diff)
X86: intel_ips, check for kzalloc properly
Stanse found that there are two NULL checks missing in ips_monitor. So check their value too and bail out appropriately if the allocation failed. While at it, add one more kfree to the fail path. It is not necessary now, but may be needed in the future when a new allocation is added. And for completeness. Also remove unneeded initialization of the variables. They are all set right after their declaration. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Matthew Garrett <mjg@redhat.com> Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/platform/x86/intel_ips.c')
-rw-r--r--drivers/platform/x86/intel_ips.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c
index cdaf40e44460..03448224aedb 100644
--- a/drivers/platform/x86/intel_ips.c
+++ b/drivers/platform/x86/intel_ips.c
@@ -920,9 +920,8 @@ static int ips_monitor(void *data)
920 struct timer_list timer; 920 struct timer_list timer;
921 unsigned long seqno_timestamp, expire, last_msecs, last_sample_period; 921 unsigned long seqno_timestamp, expire, last_msecs, last_sample_period;
922 int i; 922 int i;
923 u32 *cpu_samples = NULL, *mchp_samples = NULL, old_cpu_power; 923 u32 *cpu_samples, *mchp_samples, old_cpu_power;
924 u16 *mcp_samples = NULL, *ctv1_samples = NULL, *ctv2_samples = NULL, 924 u16 *mcp_samples, *ctv1_samples, *ctv2_samples, *mch_samples;
925 *mch_samples = NULL;
926 u8 cur_seqno, last_seqno; 925 u8 cur_seqno, last_seqno;
927 926
928 mcp_samples = kzalloc(sizeof(u16) * IPS_SAMPLE_COUNT, GFP_KERNEL); 927 mcp_samples = kzalloc(sizeof(u16) * IPS_SAMPLE_COUNT, GFP_KERNEL);
@@ -931,7 +930,8 @@ static int ips_monitor(void *data)
931 mch_samples = kzalloc(sizeof(u16) * IPS_SAMPLE_COUNT, GFP_KERNEL); 930 mch_samples = kzalloc(sizeof(u16) * IPS_SAMPLE_COUNT, GFP_KERNEL);
932 cpu_samples = kzalloc(sizeof(u32) * IPS_SAMPLE_COUNT, GFP_KERNEL); 931 cpu_samples = kzalloc(sizeof(u32) * IPS_SAMPLE_COUNT, GFP_KERNEL);
933 mchp_samples = kzalloc(sizeof(u32) * IPS_SAMPLE_COUNT, GFP_KERNEL); 932 mchp_samples = kzalloc(sizeof(u32) * IPS_SAMPLE_COUNT, GFP_KERNEL);
934 if (!mcp_samples || !ctv1_samples || !ctv2_samples || !mch_samples) { 933 if (!mcp_samples || !ctv1_samples || !ctv2_samples || !mch_samples ||
934 !cpu_samples || !mchp_samples) {
935 dev_err(&ips->dev->dev, 935 dev_err(&ips->dev->dev,
936 "failed to allocate sample array, ips disabled\n"); 936 "failed to allocate sample array, ips disabled\n");
937 kfree(mcp_samples); 937 kfree(mcp_samples);
@@ -939,6 +939,7 @@ static int ips_monitor(void *data)
939 kfree(ctv2_samples); 939 kfree(ctv2_samples);
940 kfree(mch_samples); 940 kfree(mch_samples);
941 kfree(cpu_samples); 941 kfree(cpu_samples);
942 kfree(mchp_samples);
942 kthread_stop(ips->adjust); 943 kthread_stop(ips->adjust);
943 return -ENOMEM; 944 return -ENOMEM;
944 } 945 }