[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1445264809-21917-1-git-send-email-wuninsu@gmail.com>
Date: Mon, 19 Oct 2015 14:26:49 +0000
From: Insu Yun <wuninsu@...il.com>
To: myungjoo.ham@...sung.com, kyungmin.park@...sung.com,
linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: taesoo@...ech.edu, yeongjin.jang@...ech.edu, insu@...ech.edu,
changwoo@...ech.edu, Insu Yun <wuninsu@...il.com>
Subject: [PATCH] devfreq: correctly check failed allocation
Since devm_kzalloc can be failed in memory pressure,
check return value and handle error.
Signed-off-by: Insu Yun <wuninsu@...il.com>
---
drivers/devfreq/devfreq.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index ca1b362..814089f 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -482,9 +482,23 @@ struct devfreq *devfreq_add_device(struct device *dev,
devfreq->profile->max_state *
devfreq->profile->max_state,
GFP_KERNEL);
+ if (!devfreq->trans_table) {
+ dev_err(dev, "%s: Unable to create transition table for the device\n",
+ __func__);
+ err = -ENOMEM;
+ goto err_dev;
+ }
+
devfreq->time_in_state = devm_kzalloc(dev, sizeof(unsigned int) *
devfreq->profile->max_state,
GFP_KERNEL);
+ if (!devfreq->time_in_state) {
+ dev_err(dev, "%s: Unable to create state for the device\n",
+ __func__);
+ err = -ENOMEM;
+ goto err_dev;
+ }
+
devfreq->last_stat_updated = jiffies;
dev_set_name(&devfreq->dev, "%s", dev_name(dev));
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists