mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Robin van der Gracht <robin@protonic.nl>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org, Robin van der Gracht <robin@protonic.nl>
Subject: [PATCH] lib: parameter: Free previous string value in param_string_set
Date: Thu, 16 Jun 2022 14:50:40 +0200	[thread overview]
Message-ID: <20220616125040.212193-1-robin@protonic.nl> (raw)

When the parameter has no set function the previous (saved_value) is not
freed up on completion.

Signed-off-by: Robin van der Gracht <robin@protonic.nl>
---
 lib/parameter.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/parameter.c b/lib/parameter.c
index adc3c7cdea..fe7e7b1ba4 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -262,8 +262,10 @@ static int param_string_set(struct device_d *dev, struct param_d *p, const char
 	value_new = strim(value_new);
 	*ps->value = value_new;
 
-	if (!ps->set)
+	if (!ps->set) {
+		free(value_save);
 		return 0;
+	}
 
 	ret = ps->set(p, p->driver_priv);
 	if (ret) {
-- 
2.34.1




             reply	other threads:[~2022-06-16 12:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-16 12:50 Robin van der Gracht [this message]
2022-06-16 13:50 ` Sascha Hauer
2022-06-16 15:02   ` Robin van der Gracht

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=20220616125040.212193-1-robin@protonic.nl \
    --to=robin@protonic.nl \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox