Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: kholk11@gmail.com
To: linux-arm-msm@vger.kernel.org
Cc: kholk11@gmail.com, marijns95@gmail.com, agross@kernel.org,
	daniel.lezcano@linaro.org, robh+dt@kernel.org,
	mark.rutland@arm.com, amit.kucheria@linaro.org
Subject: [PATCH v3 3/3] thermal: qcom: tsens-v1: Free memory in calibrate_v1 where required
Date: Sat,  5 Oct 2019 12:41:33 +0200	[thread overview]
Message-ID: <20191005104133.30297-4-kholk11@gmail.com> (raw)
In-Reply-To: <20191005104133.30297-1-kholk11@gmail.com>

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(-)

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


  parent reply	other threads:[~2019-10-05 10:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-05 10:41 [PATCH v3 0/3] Add TSENS support for MSM8956/76 kholk11
2019-10-05 10:41 ` [PATCH v3 1/3] thermal: qcom: tsens-v1: Add support for MSM8956 and MSM8976 kholk11
2019-10-07  5:12   ` Amit Kucheria
2019-10-16 17:20     ` Amit Kucheria
2019-10-16 18:18       ` Daniel Lezcano
2019-10-05 10:41 ` [PATCH v3 2/3] dt: thermal: tsens: Document compatible for MSM8976/56 kholk11
2019-10-07  5:11   ` Amit Kucheria
2019-10-05 10:41 ` kholk11 [this message]
2019-10-07  5:09   ` [PATCH v3 3/3] thermal: qcom: tsens-v1: Free memory in calibrate_v1 where required Amit Kucheria

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191005104133.30297-4-kholk11@gmail.com \
    --to=kholk11@gmail.com \
    --cc=agross@kernel.org \
    --cc=amit.kucheria@linaro.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=marijns95@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox