OSDN Git Service

drivers: soc: qcom: rpm_stats: Fix uninitialized buffer usage
authorMaulik Shah <mkshah@codeaurora.org>
Wed, 10 Jul 2019 04:02:13 +0000 (09:32 +0530)
committerMaulik Shah <mkshah@codeaurora.org>
Thu, 11 Jul 2019 07:57:44 +0000 (13:27 +0530)
Add matching else case to fix uninitialized buffer usage in
case of version id mismatch.

Change-Id: I7140692f62760d8f0e38f1cde4e3f9ce91a263f4
Signed-off-by: Maulik Shah <mkshah@codeaurora.org>
drivers/soc/qcom/rpm_stats.c

index ed7493d..e613da7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2017, 2019, 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
@@ -389,7 +389,7 @@ static ssize_t rpmstats_show(struct kobject *kobj,
 {
        struct msm_rpmstats_private_data *prvdata = NULL;
        struct msm_rpmstats_platform_data *pdata = NULL;
-       ssize_t ret;
+       ssize_t ret = 0;
 
        mutex_lock(&rpm_stats_mutex);
        pdata = GET_PDATA_OF_ATTR(attr);
@@ -428,9 +428,12 @@ static ssize_t rpmstats_show(struct kobject *kobj,
                else if (prvdata->platform_data->version == 2)
                        prvdata->len = msm_rpmstats_copy_stats_v2(
                                        prvdata);
+               else
+                       goto exit;
        }
 
        ret = snprintf(buf, prvdata->len, "%s", prvdata->buf);
+exit:
        iounmap(prvdata->reg_base);
 ioremap_fail:
        kfree(prvdata);