blob: e04184832085fbcaa48ef6caca9b26367c16acb4 [file] [log] [blame]
From horms@vergenet.net Tue Sep 5 10:07:57 2017
From: Simon Horman <horms@verge.net.au>
Date: Tue, 5 Sep 2017 10:06:40 +0200
Subject: [PATCH 05/13] thermal: rcar_gen3_thermal: check that TSC exists before memory allocation
To: Greg KH <gregkh@linuxfoundation.org>
Cc: ltsi-dev@lists.linuxfoundation.org, linux-renesas-soc@vger.kernel.org, Magnus Damm <magnus.damm@gmail.com>
Message-ID: <1504598808-19810-6-git-send-email-horms@verge.net.au>
From: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Move the check for a TSC resource before allocating memory for a new
TSC. If no TSC is found there is little point in allocating memory for
it.
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
(cherry picked from commit d51546c0db975a4750161d17eef62dfcf9eedc90)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
drivers/thermal/rcar_gen3_thermal.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- a/drivers/thermal/rcar_gen3_thermal.c
+++ b/drivers/thermal/rcar_gen3_thermal.c
@@ -276,16 +276,16 @@ static int rcar_gen3_thermal_probe(struc
for (i = 0; i < TSC_MAX_NUM; i++) {
struct rcar_gen3_thermal_tsc *tsc;
+ res = platform_get_resource(pdev, IORESOURCE_MEM, i);
+ if (!res)
+ break;
+
tsc = devm_kzalloc(dev, sizeof(*tsc), GFP_KERNEL);
if (!tsc) {
ret = -ENOMEM;
goto error_unregister;
}
- res = platform_get_resource(pdev, IORESOURCE_MEM, i);
- if (!res)
- break;
-
tsc->base = devm_ioremap_resource(dev, res);
if (IS_ERR(tsc->base)) {
ret = PTR_ERR(tsc->base);