Skip to content

Commit 98b7b0c

Browse files
andy-shevjic23
authored andcommitted
iio: dac: ad5770r: Put fwnode in error case during ->probe()
device_for_each_child_node() bumps a reference counting of a returned variable. We have to balance it whenever we return to the caller. Fixes: cbbb819 ("iio: dac: ad5770r: Add AD5770R support") Cc: Alexandru Tachici <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Alexandru Ardelean <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 2a54c8c commit 98b7b0c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

drivers/iio/dac/ad5770r.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -524,23 +524,29 @@ static int ad5770r_channel_config(struct ad5770r_state *st)
524524
device_for_each_child_node(&st->spi->dev, child) {
525525
ret = fwnode_property_read_u32(child, "num", &num);
526526
if (ret)
527-
return ret;
528-
if (num >= AD5770R_MAX_CHANNELS)
529-
return -EINVAL;
527+
goto err_child_out;
528+
if (num >= AD5770R_MAX_CHANNELS) {
529+
ret = -EINVAL;
530+
goto err_child_out;
531+
}
530532

531533
ret = fwnode_property_read_u32_array(child,
532534
"adi,range-microamp",
533535
tmp, 2);
534536
if (ret)
535-
return ret;
537+
goto err_child_out;
536538

537539
min = tmp[0] / 1000;
538540
max = tmp[1] / 1000;
539541
ret = ad5770r_store_output_range(st, min, max, num);
540542
if (ret)
541-
return ret;
543+
goto err_child_out;
542544
}
543545

546+
return 0;
547+
548+
err_child_out:
549+
fwnode_handle_put(child);
544550
return ret;
545551
}
546552

0 commit comments

Comments
 (0)