Skip to contentSkip to conversation

pstore/ram: Replace of_node_put with __free() for automatic cleanup

PATCH New Abhinav Jain 1 participant 1 message Jun 9, 2024 Pstore filesystem

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 pstore/ram: Replace of_node_put with __free() for automatic cleanup

Add __free(device_node) to the parent_node struct declaration. Add initialization to declaration for ensuring scope sanity. Remove of_node_put from parent_node struct.

---

Submiting v3 after making Changes as per feedback shared in v1 and v2.

Patch v1:
https://lore.kernel.org/all/[email protected]/

Patch v2:
https://lore.kernel.org/all/[email protected]/

---
 fs/pstore/ram.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/pstore/ram.c +1 -3
index b1a455f42e93..f8258e4567c3 100644
@@ -644,7 +644,7 @@ static int ramoops_parse_dt(struct platform_device *pdev,
 			    struct ramoops_platform_data *pdata)
 {
 	struct device_node *of_node = pdev->dev.of_node;
-	struct device_node *parent_node;
+	struct device_node *parent_node __free(device_node) = of_node_parent(of_node);
 	struct resource *res;
 	u32 value;
 	int ret;
@@ -704,14 +704,12 @@ static int ramoops_parse_dt(struct platform_device *pdev,
 	 * we're not a child of "reserved-memory" and mimicking the
 	 * expected behavior.
 	 */
-	parent_node = of_get_parent(of_node);
 	if (!of_node_name_eq(parent_node, "reserved-memory") &&
 	    !pdata->console_size && !pdata->ftrace_size &&
 	    !pdata->pmsg_size && !pdata->ecc_info.ecc_size) {
 		pdata->console_size = pdata->record_size;
 		pdata->pmsg_size = pdata->record_size;
 	}
-	of_node_put(parent_node);
 
 	return 0;
 }
Signature · 1 line
2.34.1