| From 4b639acb3506486f61f63e770b63363a443d4897 Mon Sep 17 00:00:00 2001 |
| From: Frank Rowand <frank.rowand@sony.com> |
| Date: Thu, 16 Apr 2020 16:42:46 -0500 |
| Subject: [PATCH] of: unittest: kmemleak on changeset destroy |
| |
| commit b3fb36ed694b05738d45218ea72cf7feb10ce2b1 upstream. |
| |
| kmemleak reports several memory leaks from devicetree unittest. |
| This is the fix for problem 1 of 5. |
| |
| of_unittest_changeset() reaches deeply into the dynamic devicetree |
| functions. Several nodes were left with an elevated reference |
| count and thus were not properly cleaned up. Fix the reference |
| counts so that the memory will be freed. |
| |
| Fixes: 201c910bd689 ("of: Transactional DT support.") |
| Reported-by: Erhard F. <erhard_f@mailbox.org> |
| Signed-off-by: Frank Rowand <frank.rowand@sony.com> |
| Signed-off-by: Rob Herring <robh@kernel.org> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c |
| index 4c019e264e21..d99426f699ef 100644 |
| --- a/drivers/of/unittest.c |
| +++ b/drivers/of/unittest.c |
| @@ -776,6 +776,10 @@ static void __init of_unittest_changeset(void) |
| unittest(!of_changeset_revert(&chgset), "revert failed\n"); |
| |
| of_changeset_destroy(&chgset); |
| + |
| + of_node_put(n1); |
| + of_node_put(n2); |
| + of_node_put(n21); |
| #endif |
| } |
| |
| -- |
| 2.7.4 |
| |