public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: frowand.list@gmail.com
To: Rob Herring <robh+dt@kernel.org>, pantelis.antoniou@konsulko.com
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	Michael Ellerman <mpe@ellerman.id.au>,
	"Erhard F." <erhard_f@mailbox.org>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Alan Tull <atull@kernel.org>
Subject: [PATCH 3/5] of: unittest: kmemleak in of_unittest_overlay_high_level()
Date: Thu, 16 Apr 2020 16:42:48 -0500	[thread overview]
Message-ID: <1587073370-25963-4-git-send-email-frowand.list@gmail.com> (raw)
In-Reply-To: <1587073370-25963-1-git-send-email-frowand.list@gmail.com>

From: Frank Rowand <frank.rowand@sony.com>

kmemleak reports several memory leaks from devicetree unittest.
This is the fix for problem 3 of 5.

of_unittest_overlay_high_level() failed to kfree the newly created
property when the property named 'name' is skipped.

Fixes: 39a751a4cb7e ("of: change overlay apply input data from unflattened to FDT")
Reported-by: Erhard F. <erhard_f@mailbox.org>
Signed-off-by: Frank Rowand <frank.rowand@sony.com>
---
 drivers/of/unittest.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 4c7818276857..f238b7a3865d 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -3094,8 +3094,11 @@ static __init void of_unittest_overlay_high_level(void)
 				goto err_unlock;
 			}
 			if (__of_add_property(of_symbols, new_prop)) {
+				kfree(new_prop->name);
+				kfree(new_prop->value);
+				kfree(new_prop);
 				/* "name" auto-generated by unflatten */
-				if (!strcmp(new_prop->name, "name"))
+				if (!strcmp(prop->name, "name"))
 					continue;
 				unittest(0, "duplicate property '%s' in overlay_base node __symbols__",
 					 prop->name);
-- 
Frank Rowand <frank.rowand@sony.com>


  parent reply	other threads:[~2020-04-16 21:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-16 21:42 [PATCH 0/5] of: unittest: kmleak detected memory leaks frowand.list
2020-04-16 21:42 ` [PATCH 1/5] of: unittest: kmemleak on changeset destroy frowand.list
2020-04-16 21:42 ` [PATCH 2/5] of: unittest: kmemleak in of_unittest_platform_populate() frowand.list
2020-04-16 21:42 ` frowand.list [this message]
2020-04-16 21:42 ` [PATCH 4/5] of: overlay: kmemleak in dup_and_fixup_symbol_prop() frowand.list
2020-04-16 21:42 ` [PATCH 5/5] of: unittest: kmemleak in duplicate property update frowand.list
2020-04-16 22:11   ` Rob Herring
2020-04-16 22:10 ` [PATCH 0/5] of: unittest: kmleak detected memory leaks Rob Herring

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=1587073370-25963-4-git-send-email-frowand.list@gmail.com \
    --to=frowand.list@gmail.com \
    --cc=atull@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=erhard_f@mailbox.org \
    --cc=geert+renesas@glider.be \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=pantelis.antoniou@konsulko.com \
    --cc=robh+dt@kernel.org \
    /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