diff mbox

cpufreq: kryo: Fix possible error code dereference

Message ID 20180614202921.32535-1-ilia.lin@gmail.com (mailing list archive)
State Changes Requested, archived
Headers show

Commit Message

Ilia Lin June 14, 2018, 8:29 p.m. UTC
From: Ilia Lin <ilia.lin@gmail.com>

In event of error returned by the nvmem_cell_read() non-pointer value
may be dereferenced. Fix this with error handling.

Signed-off-by: Ilia Lin <ilia.lin@gmail.com>
---
 drivers/cpufreq/qcom-cpufreq-kryo.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Viresh Kumar June 15, 2018, 2:46 a.m. UTC | #1
On 14-06-18, 22:29, ilia.lin@gmail.com wrote:
> From: Ilia Lin <ilia.lin@gmail.com>
> 
> In event of error returned by the nvmem_cell_read() non-pointer value
> may be dereferenced. Fix this with error handling.
> 
> Signed-off-by: Ilia Lin <ilia.lin@gmail.com>

Fixes tag ?

> ---
>  drivers/cpufreq/qcom-cpufreq-kryo.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/cpufreq/qcom-cpufreq-kryo.c b/drivers/cpufreq/qcom-cpufreq-kryo.c
> index d049fe4b80c4..5e9511223ce9 100644
> --- a/drivers/cpufreq/qcom-cpufreq-kryo.c
> +++ b/drivers/cpufreq/qcom-cpufreq-kryo.c
> @@ -115,6 +115,8 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)
>  
>  	speedbin = nvmem_cell_read(speedbin_nvmem, &len);
>  	nvmem_cell_put(speedbin_nvmem);
> +	if (IS_ERR(speedbin))
> +		return PTR_ERR(speedbin);
>  
>  	switch (msm8996_version) {
>  	case MSM8996_V3:
> -- 
> 2.11.0
diff mbox

Patch

diff --git a/drivers/cpufreq/qcom-cpufreq-kryo.c b/drivers/cpufreq/qcom-cpufreq-kryo.c
index d049fe4b80c4..5e9511223ce9 100644
--- a/drivers/cpufreq/qcom-cpufreq-kryo.c
+++ b/drivers/cpufreq/qcom-cpufreq-kryo.c
@@ -115,6 +115,8 @@  static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)
 
 	speedbin = nvmem_cell_read(speedbin_nvmem, &len);
 	nvmem_cell_put(speedbin_nvmem);
+	if (IS_ERR(speedbin))
+		return PTR_ERR(speedbin);
 
 	switch (msm8996_version) {
 	case MSM8996_V3: