diff mbox series

sound:rk817 reduce memmory leak chance with __free

Message ID 20240618135845.13387-1-david.hunter.linux@gmail.com (mailing list archive)
State New, archived
Headers show
Series sound:rk817 reduce memmory leak chance with __free | expand

Commit Message

David Hunter June 18, 2024, 1:58 p.m. UTC
Using the __free function instead of of_node_put helps with
preventing memory leaks.

The kernel was cross-compiled and installed on an arm64 system.

Unable to test if the sound system still worked because I was on an
Arm64 virtual machine, and I could not get the sound to work on
the machine.

I could not find unit tests or kselftests that utilize code in
rk817_codec.c. If there are any tests that I should run, please
let me know.

Signed-off-by: David Hunter <david.hunter.linux@gmail.com>
---
 sound/soc/codecs/rk817_codec.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/codecs/rk817_codec.c b/sound/soc/codecs/rk817_codec.c
index d4da98469f8b..1ad576cd7ea2 100644
--- a/sound/soc/codecs/rk817_codec.c
+++ b/sound/soc/codecs/rk817_codec.c
@@ -456,9 +456,9 @@  static const struct snd_soc_component_driver soc_codec_dev_rk817 = {
 static void rk817_codec_parse_dt_property(struct device *dev,
 					 struct rk817_codec_priv *rk817)
 {
-	struct device_node *node;
+	struct device_node *node __free(device_node) = of_get_child_by_name(dev->parent->of_node,
+									    "codec");
 
-	node = of_get_child_by_name(dev->parent->of_node, "codec");
 	if (!node) {
 		dev_dbg(dev, "%s() Can not get child: codec\n",
 			__func__);
@@ -466,8 +466,6 @@  static void rk817_codec_parse_dt_property(struct device *dev,
 
 	rk817->mic_in_differential =
 			of_property_read_bool(node, "rockchip,mic-in-differential");
-
-	of_node_put(node);
 }
 
 static int rk817_platform_probe(struct platform_device *pdev)