* [PATCH] cpufreq: kryo: Fix possible error code dereference
@ 2018-06-14 20:29 ilia.lin
2018-06-15 2:46 ` Viresh Kumar
2018-06-17 19:58 ` [PATCH v2] " ilia.lin
0 siblings, 2 replies; 5+ messages in thread
From: ilia.lin @ 2018-06-14 20:29 UTC (permalink / raw)
To: Ilia Lin, Ilia Lin, Rafael J . Wysocki, Viresh Kumar
Cc: Dan Carpenter, linux-pm, linux-kernel
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(+)
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] cpufreq: kryo: Fix possible error code dereference
2018-06-14 20:29 [PATCH] cpufreq: kryo: Fix possible error code dereference ilia.lin
@ 2018-06-15 2:46 ` Viresh Kumar
2018-06-17 19:58 ` [PATCH v2] " ilia.lin
1 sibling, 0 replies; 5+ messages in thread
From: Viresh Kumar @ 2018-06-15 2:46 UTC (permalink / raw)
To: ilia.lin
Cc: Ilia Lin, Rafael J . Wysocki, Dan Carpenter, linux-pm, linux-kernel
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
--
viresh
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] cpufreq: kryo: Fix possible error code dereference
2018-06-14 20:29 [PATCH] cpufreq: kryo: Fix possible error code dereference ilia.lin
2018-06-15 2:46 ` Viresh Kumar
@ 2018-06-17 19:58 ` ilia.lin
2018-06-18 4:55 ` Viresh Kumar
1 sibling, 1 reply; 5+ messages in thread
From: ilia.lin @ 2018-06-17 19:58 UTC (permalink / raw)
To: ilia.lin; +Cc: Rafael J. Wysocki, Viresh Kumar, linux-pm, linux-kernel
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.
Additionally free the allocated speedbin buffer, as per the API.
Fixes: 9ce36edd1a52 (cpufreq: Add Kryo CPU scaling driver)
Signed-off-by: Ilia Lin <ilia.lin@gmail.com>
---
drivers/cpufreq/qcom-cpufreq-kryo.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/cpufreq/qcom-cpufreq-kryo.c b/drivers/cpufreq/qcom-cpufreq-kryo.c
index d049fe4b80c4..74b9b93d511b 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:
@@ -127,6 +129,7 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)
BUG();
break;
}
+ kfree(speedbin);
for_each_possible_cpu(cpu) {
cpu_dev = get_cpu_device(cpu);
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] cpufreq: kryo: Fix possible error code dereference
2018-06-17 19:58 ` [PATCH v2] " ilia.lin
@ 2018-06-18 4:55 ` Viresh Kumar
2018-06-21 13:22 ` Rafael J. Wysocki
0 siblings, 1 reply; 5+ messages in thread
From: Viresh Kumar @ 2018-06-18 4:55 UTC (permalink / raw)
To: ilia.lin; +Cc: Rafael J. Wysocki, linux-pm, linux-kernel
On 17-06-18, 21:58, 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.
> Additionally free the allocated speedbin buffer, as per the API.
>
> Fixes: 9ce36edd1a52 (cpufreq: Add Kryo CPU scaling driver)
> Signed-off-by: Ilia Lin <ilia.lin@gmail.com>
> ---
> drivers/cpufreq/qcom-cpufreq-kryo.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/cpufreq/qcom-cpufreq-kryo.c b/drivers/cpufreq/qcom-cpufreq-kryo.c
> index d049fe4b80c4..74b9b93d511b 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:
> @@ -127,6 +129,7 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)
> BUG();
> break;
> }
> + kfree(speedbin);
>
> for_each_possible_cpu(cpu) {
> cpu_dev = get_cpu_device(cpu);
Ideally this should have been two patches as you were fixing two
different problems. But anyway, you can go through this time.
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] cpufreq: kryo: Fix possible error code dereference
2018-06-18 4:55 ` Viresh Kumar
@ 2018-06-21 13:22 ` Rafael J. Wysocki
0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2018-06-21 13:22 UTC (permalink / raw)
To: Viresh Kumar, ilia.lin; +Cc: linux-pm, linux-kernel
On Monday, June 18, 2018 6:55:23 AM CEST Viresh Kumar wrote:
> On 17-06-18, 21:58, 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.
> > Additionally free the allocated speedbin buffer, as per the API.
> >
> > Fixes: 9ce36edd1a52 (cpufreq: Add Kryo CPU scaling driver)
> > Signed-off-by: Ilia Lin <ilia.lin@gmail.com>
> > ---
> > drivers/cpufreq/qcom-cpufreq-kryo.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/cpufreq/qcom-cpufreq-kryo.c b/drivers/cpufreq/qcom-cpufreq-kryo.c
> > index d049fe4b80c4..74b9b93d511b 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:
> > @@ -127,6 +129,7 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)
> > BUG();
> > break;
> > }
> > + kfree(speedbin);
> >
> > for_each_possible_cpu(cpu) {
> > cpu_dev = get_cpu_device(cpu);
>
> Ideally this should have been two patches as you were fixing two
> different problems. But anyway, you can go through this time.
>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Patch applied, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-06-21 13:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-14 20:29 [PATCH] cpufreq: kryo: Fix possible error code dereference ilia.lin
2018-06-15 2:46 ` Viresh Kumar
2018-06-17 19:58 ` [PATCH v2] " ilia.lin
2018-06-18 4:55 ` Viresh Kumar
2018-06-21 13:22 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).