Skip to content

Commit abba116

Browse files
shivanigupta-devbroonie
authored andcommitted
spi: spi-s3c64xx.c: Remove of_node_put for auto cleanup
Use the scope based of_node_put() cleanup in s3c64xx_spi_csinfo to automatically release the device node with the __free() cleanup handler Initialize data_np at the point of declaration for clarity of scope. This change reduces the risk of memory leaks and simplifies the code by removing manual node put call. Suggested-by: Julia Lawall <[email protected]> Signed-off-by: Shivani Gupta <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 856d9e8 commit abba116

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/spi/spi-s3c64xx.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_target_ctrldata(
950950
struct spi_device *spi)
951951
{
952952
struct s3c64xx_spi_csinfo *cs;
953-
struct device_node *target_np, *data_np = NULL;
953+
struct device_node *target_np;
954954
u32 fb_delay = 0;
955955

956956
target_np = spi->dev.of_node;
@@ -963,15 +963,15 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_target_ctrldata(
963963
if (!cs)
964964
return ERR_PTR(-ENOMEM);
965965

966-
data_np = of_get_child_by_name(target_np, "controller-data");
966+
struct device_node *data_np __free(device_node) =
967+
of_get_child_by_name(target_np, "controller-data");
967968
if (!data_np) {
968969
dev_info(&spi->dev, "feedback delay set to default (0)\n");
969970
return cs;
970971
}
971972

972973
of_property_read_u32(data_np, "samsung,spi-feedback-delay", &fb_delay);
973974
cs->fb_delay = fb_delay;
974-
of_node_put(data_np);
975975
return cs;
976976
}
977977

0 commit comments

Comments
 (0)