diff options
author | Rob Herring <robh@kernel.org> | 2024-04-09 13:59:39 -0500 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2024-04-15 08:40:40 -0500 |
commit | 1c5e3d9bf33b811e1c6dd9081b322004acc4a1fd (patch) | |
tree | e3de2e82c97a3114bbfc3d2e32659215f52c2c4f /drivers/of/unittest.c | |
parent | 15f3df361720de343d125ca01b7b456b8d16327f (diff) |
of: Add a helper to free property struct
Freeing a property struct is 3 kfree()'s which is duplicated in multiple
spots. Add a helper, __of_prop_free(), and replace all the open coded
cases in the DT code.
Reviewed-by: Saravana Kannan <saravanak@google.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20240409-dt-cleanup-free-v2-1-5b419a4af38d@kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/of/unittest.c')
-rw-r--r-- | drivers/of/unittest.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 6b5c36b6a758..a8c01c953a29 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -795,15 +795,11 @@ static void __init of_unittest_property_copy(void) new = __of_prop_dup(&p1, GFP_KERNEL); unittest(new && propcmp(&p1, new), "empty property didn't copy correctly\n"); - kfree(new->value); - kfree(new->name); - kfree(new); + __of_prop_free(new); new = __of_prop_dup(&p2, GFP_KERNEL); unittest(new && propcmp(&p2, new), "non-empty property didn't copy correctly\n"); - kfree(new->value); - kfree(new->name); - kfree(new); + __of_prop_free(new); #endif } @@ -3718,9 +3714,7 @@ 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); + __of_prop_free(new_prop); /* "name" auto-generated by unflatten */ if (!strcmp(prop->name, "name")) continue; |