diff mbox series

[v3,3/3] thermal: qcom: tsens-v1: Free memory in calibrate_v1 where required

Message ID 20191005104133.30297-4-kholk11@gmail.com (mailing list archive)
State New, archived
Headers show
Series Add TSENS support for MSM8956/76 | expand

Commit Message

AngeloGioacchino Del Regno Oct. 5, 2019, 10:41 a.m. UTC
From: AngeloGioacchino Del Regno <kholk11@gmail.com>

The calibrate_v1 function allocates the qfprom_cdata variable
during qfprom_read, but it never gets freed: properly kfree it.

Signed-off-by: AngeloGioacchino Del Regno <kholk11@gmail.com>
---
 drivers/thermal/qcom/tsens-v1.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Amit Kucheria Oct. 7, 2019, 5:09 a.m. UTC | #1
On Sat, Oct 5, 2019 at 4:11 PM <kholk11@gmail.com> wrote:
>
> From: AngeloGioacchino Del Regno <kholk11@gmail.com>
>
> The calibrate_v1 function allocates the qfprom_cdata variable
> during qfprom_read, but it never gets freed: properly kfree it.

This has already been fixed upstream. So this patch isn't required.

> Signed-off-by: AngeloGioacchino Del Regno <kholk11@gmail.com>
> ---
>  drivers/thermal/qcom/tsens-v1.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c
> index 3c85a698123a..017501f37a41 100644
> --- a/drivers/thermal/qcom/tsens-v1.c
> +++ b/drivers/thermal/qcom/tsens-v1.c
> @@ -173,8 +173,10 @@ static int calibrate_v1(struct tsens_priv *priv)
>         int i;
>
>         qfprom_cdata = (u32 *)qfprom_read(priv->dev, "calib");
> -       if (IS_ERR(qfprom_cdata))
> +       if (IS_ERR(qfprom_cdata)) {
> +               kfree(qfprom_cdata);
>                 return PTR_ERR(qfprom_cdata);
> +       }
>
>         mode = (qfprom_cdata[4] & CAL_SEL_MASK) >> CAL_SEL_SHIFT;
>         dev_dbg(priv->dev, "calibration mode is %d\n", mode);
> @@ -225,6 +227,7 @@ static int calibrate_v1(struct tsens_priv *priv)
>         }
>
>         compute_intercept_slope(priv, p1, p2, mode);
> +       kfree(qfprom_cdata);
>
>         return 0;
>  }
> --
> 2.21.0
>
diff mbox series

Patch

diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c
index 3c85a698123a..017501f37a41 100644
--- a/drivers/thermal/qcom/tsens-v1.c
+++ b/drivers/thermal/qcom/tsens-v1.c
@@ -173,8 +173,10 @@  static int calibrate_v1(struct tsens_priv *priv)
 	int i;
 
 	qfprom_cdata = (u32 *)qfprom_read(priv->dev, "calib");
-	if (IS_ERR(qfprom_cdata))
+	if (IS_ERR(qfprom_cdata)) {
+		kfree(qfprom_cdata);
 		return PTR_ERR(qfprom_cdata);
+	}
 
 	mode = (qfprom_cdata[4] & CAL_SEL_MASK) >> CAL_SEL_SHIFT;
 	dev_dbg(priv->dev, "calibration mode is %d\n", mode);
@@ -225,6 +227,7 @@  static int calibrate_v1(struct tsens_priv *priv)
 	}
 
 	compute_intercept_slope(priv, p1, p2, mode);
+	kfree(qfprom_cdata);
 
 	return 0;
 }