* [PATCH][next] thermal: qcom: tsens-v1: fix kfree of a non-pointer value
@ 2019-10-22 11:18 Colin King
2019-10-22 12:39 ` AngeloGioacchino Del Regno
2019-10-22 13:06 ` Amit Kucheria
0 siblings, 2 replies; 4+ messages in thread
From: Colin King @ 2019-10-22 11:18 UTC (permalink / raw)
To: Amit Kucheria, Andy Gross, Zhang Rui, Eduardo Valentin,
Daniel Lezcano, AngeloGioacchino Del Regno, linux-pm,
linux-arm-msm
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently the kfree of pointer qfprom_cdata is kfreeing an
error value that has been cast to a pointer rather than a
valid address. Fix this by removing the kfree.
Fixes: 95ededc17e4e ("thermal: qcom: tsens-v1: Add support for MSM8956 and MSM8976")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/thermal/qcom/tsens-v1.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c
index 2d1077b64887..bd2ddb684a45 100644
--- a/drivers/thermal/qcom/tsens-v1.c
+++ b/drivers/thermal/qcom/tsens-v1.c
@@ -240,10 +240,8 @@ static int calibrate_8976(struct tsens_priv *priv)
u32 *qfprom_cdata;
qfprom_cdata = (u32 *)qfprom_read(priv->dev, "calib");
- if (IS_ERR(qfprom_cdata)) {
- kfree(qfprom_cdata);
+ if (IS_ERR(qfprom_cdata))
return PTR_ERR(qfprom_cdata);
- }
mode = (qfprom_cdata[4] & MSM8976_CAL_SEL_MASK);
dev_dbg(priv->dev, "calibration mode is %d\n", mode);
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH][next] thermal: qcom: tsens-v1: fix kfree of a non-pointer value
2019-10-22 11:18 [PATCH][next] thermal: qcom: tsens-v1: fix kfree of a non-pointer value Colin King
@ 2019-10-22 12:39 ` AngeloGioacchino Del Regno
2019-10-22 13:06 ` Amit Kucheria
1 sibling, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2019-10-22 12:39 UTC (permalink / raw)
To: Colin King
Cc: Amit Kucheria, Andy Gross, Zhang Rui, Eduardo Valentin,
Daniel Lezcano, linux-pm, MSM, kernel-janitors, linux-kernel
Il giorno mar 22 ott 2019 alle ore 13:18 Colin King
<colin.king@canonical.com> ha scritto:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the kfree of pointer qfprom_cdata is kfreeing an
> error value that has been cast to a pointer rather than a
> valid address. Fix this by removing the kfree.
>
> Fixes: 95ededc17e4e ("thermal: qcom: tsens-v1: Add support for MSM8956 and MSM8976")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/thermal/qcom/tsens-v1.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c
> index 2d1077b64887..bd2ddb684a45 100644
> --- a/drivers/thermal/qcom/tsens-v1.c
> +++ b/drivers/thermal/qcom/tsens-v1.c
> @@ -240,10 +240,8 @@ static int calibrate_8976(struct tsens_priv *priv)
> u32 *qfprom_cdata;
>
> qfprom_cdata = (u32 *)qfprom_read(priv->dev, "calib");
> - if (IS_ERR(qfprom_cdata)) {
> - kfree(qfprom_cdata);
> + if (IS_ERR(qfprom_cdata))
> return PTR_ERR(qfprom_cdata);
> - }
>
> mode = (qfprom_cdata[4] & MSM8976_CAL_SEL_MASK);
> dev_dbg(priv->dev, "calibration mode is %d\n", mode);
> --
> 2.20.1
>
I confirm that was one stupid mistake. I was about to send the same patch, and I
can confirm that this fix is working. Tested on my Xperia X Compact.
Tested-by: AngeloGioacchino Del Regno <kholk11@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] thermal: qcom: tsens-v1: fix kfree of a non-pointer value
2019-10-22 11:18 [PATCH][next] thermal: qcom: tsens-v1: fix kfree of a non-pointer value Colin King
2019-10-22 12:39 ` AngeloGioacchino Del Regno
@ 2019-10-22 13:06 ` Amit Kucheria
2019-10-22 16:44 ` Srinivas Kandagatla
1 sibling, 1 reply; 4+ messages in thread
From: Amit Kucheria @ 2019-10-22 13:06 UTC (permalink / raw)
To: Colin King, Srinivas Kandagatla
Cc: Andy Gross, Zhang Rui, Eduardo Valentin, Daniel Lezcano,
AngeloGioacchino Del Regno, Linux PM list, linux-arm-msm,
kernel-janitors, Linux Kernel Mailing List
On Tue, Oct 22, 2019 at 4:48 PM Colin King <colin.king@canonical.com> wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the kfree of pointer qfprom_cdata is kfreeing an
> error value that has been cast to a pointer rather than a
> valid address. Fix this by removing the kfree.
Hmm, we just added this to other places[1] as a fix for mem leaks
using the nvmem api.
I think we need to fix up the qfprom_read wrapper. Srini?
[1] https://lore.kernel.org/stable/20191010083616.685532154@linuxfoundation.org/
> Fixes: 95ededc17e4e ("thermal: qcom: tsens-v1: Add support for MSM8956 and MSM8976")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/thermal/qcom/tsens-v1.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c
> index 2d1077b64887..bd2ddb684a45 100644
> --- a/drivers/thermal/qcom/tsens-v1.c
> +++ b/drivers/thermal/qcom/tsens-v1.c
> @@ -240,10 +240,8 @@ static int calibrate_8976(struct tsens_priv *priv)
> u32 *qfprom_cdata;
>
> qfprom_cdata = (u32 *)qfprom_read(priv->dev, "calib");
> - if (IS_ERR(qfprom_cdata)) {
> - kfree(qfprom_cdata);
> + if (IS_ERR(qfprom_cdata))
> return PTR_ERR(qfprom_cdata);
> - }
>
> mode = (qfprom_cdata[4] & MSM8976_CAL_SEL_MASK);
> dev_dbg(priv->dev, "calibration mode is %d\n", mode);
> --
> 2.20.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] thermal: qcom: tsens-v1: fix kfree of a non-pointer value
2019-10-22 13:06 ` Amit Kucheria
@ 2019-10-22 16:44 ` Srinivas Kandagatla
0 siblings, 0 replies; 4+ messages in thread
From: Srinivas Kandagatla @ 2019-10-22 16:44 UTC (permalink / raw)
To: Amit Kucheria, Colin King
Cc: Andy Gross, Zhang Rui, Eduardo Valentin, Daniel Lezcano,
AngeloGioacchino Del Regno, Linux PM list, linux-arm-msm,
kernel-janitors, Linux Kernel Mailing List
On 22/10/2019 14:06, Amit Kucheria wrote:
> On Tue, Oct 22, 2019 at 4:48 PM Colin King <colin.king@canonical.com> wrote:
>>
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Currently the kfree of pointer qfprom_cdata is kfreeing an
>> error value that has been cast to a pointer rather than a
>> valid address. Fix this by removing the kfree.
>
> Hmm, we just added this to other places[1] as a fix for mem leaks
> using the nvmem api. >
This patch has nothing to do with the memleak fix.
> I think we need to fix up the qfprom_read wrapper. Srini?
not sure how we can fix that, as the pointer returned from read is needs
to be freed by the caller after its done with it!
--srini
>
> [1] https://lore.kernel.org/stable/20191010083616.685532154@linuxfoundation.org/
>
>> Fixes: 95ededc17e4e ("thermal: qcom: tsens-v1: Add support for MSM8956 and MSM8976")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>> drivers/thermal/qcom/tsens-v1.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c
>> index 2d1077b64887..bd2ddb684a45 100644
>> --- a/drivers/thermal/qcom/tsens-v1.c
>> +++ b/drivers/thermal/qcom/tsens-v1.c
>> @@ -240,10 +240,8 @@ static int calibrate_8976(struct tsens_priv *priv)
>> u32 *qfprom_cdata;
>>
>> qfprom_cdata = (u32 *)qfprom_read(priv->dev, "calib");
>> - if (IS_ERR(qfprom_cdata)) {
>> - kfree(qfprom_cdata);
>> + if (IS_ERR(qfprom_cdata))
>> return PTR_ERR(qfprom_cdata);
>> - }
>>
>> mode = (qfprom_cdata[4] & MSM8976_CAL_SEL_MASK);
>> dev_dbg(priv->dev, "calibration mode is %d\n", mode);
>> --
>> 2.20.1
>>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-10-22 16:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-22 11:18 [PATCH][next] thermal: qcom: tsens-v1: fix kfree of a non-pointer value Colin King
2019-10-22 12:39 ` AngeloGioacchino Del Regno
2019-10-22 13:06 ` Amit Kucheria
2019-10-22 16:44 ` Srinivas Kandagatla
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).