Skip to content

Commit b925fb4

Browse files
author
Hans Verkuil
committed
media: i2c: adp1653: don't reuse the same node pointer
The child device_node pointer was used for two different children. This confused smatch, causing this warning: drivers/media/i2c/adp1653.c:444 adp1653_of_init() warn: missing unwind goto? Use two different pointers, one for each child node, and add separate goto labels for each node as well. This also improves error logging since it will now state for which node the property was missing. Signed-off-by: Hans Verkuil <[email protected]> Acked-by: Sakari Ailus <[email protected]> [hverkuil: fix typo: childs -> children]
1 parent d13fabf commit b925fb4

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

drivers/media/i2c/adp1653.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -411,43 +411,44 @@ static int adp1653_of_init(struct i2c_client *client,
411411
struct device_node *node)
412412
{
413413
struct adp1653_platform_data *pd;
414-
struct device_node *child;
414+
struct device_node *node_indicator = NULL;
415+
struct device_node *node_flash;
415416

416417
pd = devm_kzalloc(&client->dev, sizeof(*pd), GFP_KERNEL);
417418
if (!pd)
418419
return -ENOMEM;
419420
flash->platform_data = pd;
420421

421-
child = of_get_child_by_name(node, "flash");
422-
if (!child)
422+
node_flash = of_get_child_by_name(node, "flash");
423+
if (!node_flash)
423424
return -EINVAL;
424425

425-
if (of_property_read_u32(child, "flash-timeout-us",
426+
if (of_property_read_u32(node_flash, "flash-timeout-us",
426427
&pd->max_flash_timeout))
427428
goto err;
428429

429-
if (of_property_read_u32(child, "flash-max-microamp",
430+
if (of_property_read_u32(node_flash, "flash-max-microamp",
430431
&pd->max_flash_intensity))
431432
goto err;
432433

433434
pd->max_flash_intensity /= 1000;
434435

435-
if (of_property_read_u32(child, "led-max-microamp",
436+
if (of_property_read_u32(node_flash, "led-max-microamp",
436437
&pd->max_torch_intensity))
437438
goto err;
438439

439440
pd->max_torch_intensity /= 1000;
440-
of_node_put(child);
441441

442-
child = of_get_child_by_name(node, "indicator");
443-
if (!child)
444-
return -EINVAL;
442+
node_indicator = of_get_child_by_name(node, "indicator");
443+
if (!node_indicator)
444+
goto err;
445445

446-
if (of_property_read_u32(child, "led-max-microamp",
446+
if (of_property_read_u32(node_indicator, "led-max-microamp",
447447
&pd->max_indicator_intensity))
448448
goto err;
449449

450-
of_node_put(child);
450+
of_node_put(node_flash);
451+
of_node_put(node_indicator);
451452

452453
pd->enable_gpio = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW);
453454
if (IS_ERR(pd->enable_gpio)) {
@@ -458,7 +459,8 @@ static int adp1653_of_init(struct i2c_client *client,
458459
return 0;
459460
err:
460461
dev_err(&client->dev, "Required property not found\n");
461-
of_node_put(child);
462+
of_node_put(node_flash);
463+
of_node_put(node_indicator);
462464
return -EINVAL;
463465
}
464466

0 commit comments

Comments
 (0)