OSDN Git Service

msm: kgsl: Add NULL check for kgsl_midframe before accessing it
authorRajesh Kemisetti <rajeshk@codeaurora.org>
Thu, 2 Feb 2017 15:02:29 +0000 (20:32 +0530)
committerRajesh Kemisetti <rajeshk@codeaurora.org>
Mon, 6 Feb 2017 11:01:19 +0000 (16:31 +0530)
in kgsl_pwrscale_init(), add missing NULL check for kgsl_midframe
to avoid further accessing, in case if memory is not available.

Change-Id: If6a4e59d4675fe67aefc63d7f8251f4d28ddeec5
Signed-off-by: Rajesh Kemisetti <rajeshk@codeaurora.org>
drivers/gpu/msm/kgsl_pwrscale.c

index 413a309..7f93ab8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2010-2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -917,11 +917,15 @@ int kgsl_pwrscale_init(struct device *dev, const char *governor)
                        "qcom,enable-midframe-timer")) {
                kgsl_midframe = kzalloc(
                                sizeof(struct kgsl_midframe_info), GFP_KERNEL);
-               hrtimer_init(&kgsl_midframe->timer,
-                               CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-               kgsl_midframe->timer.function =
-                               kgsl_pwrscale_midframe_timer;
-               kgsl_midframe->device = device;
+               if (kgsl_midframe) {
+                       hrtimer_init(&kgsl_midframe->timer,
+                                       CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+                       kgsl_midframe->timer.function =
+                                       kgsl_pwrscale_midframe_timer;
+                       kgsl_midframe->device = device;
+               } else
+                       KGSL_PWR_ERR(device,
+                               "Failed to enable-midframe-timer feature\n");
        }
 
        /*