PM / devfreq: Check get_dev_status in devfreq_update_stats
authorDong Aisheng <aisheng.dong@nxp.com>
Tue, 9 Mar 2021 12:58:38 +0000 (20:58 +0800)
committerChanwoo Choi <cw00.choi@samsung.com>
Thu, 8 Apr 2021 04:14:51 +0000 (13:14 +0900)
Check .get_dev_status() in devfreq_update_stats in case it's abused
when a device does not provide it.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
drivers/devfreq/governor.h

index 70f44b3ca42e60c2aa5cc6b440ff38846c350cb9..244634465170483b4e8d4d46bcc6b2148fc08162 100644 (file)
@@ -91,6 +91,9 @@ int devfreq_update_target(struct devfreq *devfreq, unsigned long freq);
 
 static inline int devfreq_update_stats(struct devfreq *df)
 {
+       if (!df->profile->get_dev_status)
+               return -EINVAL;
+
        return df->profile->get_dev_status(df->dev.parent, &df->last_status);
 }
 #endif /* _GOVERNOR_H */