lkml.org 
[lkml]   [2015]   [Oct]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] devfreq: correctly check failed allocation
Date
Since devm_kzalloc can be failed in memory pressure,
check return value and handle error.

Signed-off-by: Insu Yun <wuninsu@gmail.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


\
 
 \ /
  Last update: 2015-10-19 16:41    [W:0.029 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site