Skip to content

Commit d51546c

Browse files
Niklas SöderlundEduardo Valentin
authored andcommitted
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 <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Reviewed-by: Wolfram Sang <[email protected]> Signed-off-by: Eduardo Valentin <[email protected]>
1 parent 100cfbc commit d51546c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/thermal/rcar_gen3_thermal.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,16 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
276276
for (i = 0; i < TSC_MAX_NUM; i++) {
277277
struct rcar_gen3_thermal_tsc *tsc;
278278

279+
res = platform_get_resource(pdev, IORESOURCE_MEM, i);
280+
if (!res)
281+
break;
282+
279283
tsc = devm_kzalloc(dev, sizeof(*tsc), GFP_KERNEL);
280284
if (!tsc) {
281285
ret = -ENOMEM;
282286
goto error_unregister;
283287
}
284288

285-
res = platform_get_resource(pdev, IORESOURCE_MEM, i);
286-
if (!res)
287-
break;
288-
289289
tsc->base = devm_ioremap_resource(dev, res);
290290
if (IS_ERR(tsc->base)) {
291291
ret = PTR_ERR(tsc->base);

0 commit comments

Comments
 (0)