diff options
author | Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> | 2017-03-29 14:43:52 -0400 |
---|---|---|
committer | Eduardo Valentin <edubezval@gmail.com> | 2017-03-31 00:41:48 -0400 |
commit | d51546c0db975a4750161d17eef62dfcf9eedc90 (patch) | |
tree | 86f6a3a865e2851724e78285249567ff7934e194 /drivers | |
parent | 100cfbcf2580b0605f50af32fefd9c8d1d8357fb (diff) |
thermal: rcar_gen3_thermal: check that TSC exists before memory allocation
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/thermal/rcar_gen3_thermal.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c index cb5c362c0000..9b6bc03dd142 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c | |||
@@ -276,16 +276,16 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) | |||
276 | for (i = 0; i < TSC_MAX_NUM; i++) { | 276 | for (i = 0; i < TSC_MAX_NUM; i++) { |
277 | struct rcar_gen3_thermal_tsc *tsc; | 277 | struct rcar_gen3_thermal_tsc *tsc; |
278 | 278 | ||
279 | res = platform_get_resource(pdev, IORESOURCE_MEM, i); | ||
280 | if (!res) | ||
281 | break; | ||
282 | |||
279 | tsc = devm_kzalloc(dev, sizeof(*tsc), GFP_KERNEL); | 283 | tsc = devm_kzalloc(dev, sizeof(*tsc), GFP_KERNEL); |
280 | if (!tsc) { | 284 | if (!tsc) { |
281 | ret = -ENOMEM; | 285 | ret = -ENOMEM; |
282 | goto error_unregister; | 286 | goto error_unregister; |
283 | } | 287 | } |
284 | 288 | ||
285 | res = platform_get_resource(pdev, IORESOURCE_MEM, i); | ||
286 | if (!res) | ||
287 | break; | ||
288 | |||
289 | tsc->base = devm_ioremap_resource(dev, res); | 289 | tsc->base = devm_ioremap_resource(dev, res); |
290 | if (IS_ERR(tsc->base)) { | 290 | if (IS_ERR(tsc->base)) { |
291 | ret = PTR_ERR(tsc->base); | 291 | ret = PTR_ERR(tsc->base); |