All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Hunter <david.hunter.linux@gmail.com>
To: perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com, broonie@kernel.org
Cc: David Hunter <david.hunter.linux@gmail.com>,
	linux-sound@vger.kernel.org, julia.lawall@inria.fr,
	skhan@linuxfoundation.org, javier.carrasco.cruz@gmail.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH] sound:rk817 reduce memmory leak chance with __free
Date: Tue, 18 Jun 2024 09:58:45 -0400	[thread overview]
Message-ID: <20240618135845.13387-1-david.hunter.linux@gmail.com> (raw)

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 --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)
-- 
2.34.1


             reply	other threads:[~2024-06-18 13:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-18 13:58 David Hunter [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-04-30  5:59 [PATCH] sound: rk817 reduce memmory leak chance with __free David Hunter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240618135845.13387-1-david.hunter.linux@gmail.com \
    --to=david.hunter.linux@gmail.com \
    --cc=broonie@kernel.org \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=julia.lawall@inria.fr \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=skhan@linuxfoundation.org \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.