Skip to contentSkip to conversation

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

PATCH Superseded Abhinav Jain 2 participants 3 messages Jun 5, 2024 – Jun 9, 2024 Pstore filesystem

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

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

Add __free(device_node) to the parent_node struct declaration Add changes to incorporate the review comments from v1

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

Changes since v1:
- Moved the variable definition back to the top of the function body

---
 fs/pstore/ram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/pstore/ram.c +1 -1
index 14f2f4864e48..f8258e4567c3 100644
@@ -644,6 +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 __free(device_node) = of_node_parent(of_node);
 	struct resource *res;
 	u32 value;
 	int ret;
@@ -703,7 +704,6 @@ static int ramoops_parse_dt(struct platform_device *pdev,
 	 * we're not a child of "reserved-memory" and mimicking the
 	 * expected behavior.
 	 */
-	struct device_node *parent_node __free(device_node) = of_node_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) {
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 10 lines · Abhinav Jain

Add __free(device_node) to the parent_node struct declaration Add changes to incorporate the review comments from v1

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

Changes since v1:
- Moved the variable definition back to the top of the function body

The history and version links should be below the "---" line.

But more importantly, please base your patch on the upstream tree, rather than on your v1 patch. :) (i.e. squash your v1 and v2 together).

-Kees

Quoted 27 lines
---
 fs/pstore/ram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/pstore/ram.c +1 -1
index 14f2f4864e48..f8258e4567c3 100644
@@ -644,6 +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 __free(device_node) = of_node_parent(of_node);
 	struct resource *res;
 	u32 value;
 	int ret;
@@ -703,7 +704,6 @@ static int ramoops_parse_dt(struct platform_device *pdev,
 	 * we're not a child of "reserved-memory" and mimicking the
 	 * expected behavior.
 	 */
-	struct device_node *parent_node __free(device_node) = of_node_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) {
Signature · 1 line
2.34.1
Signature · 1 line
Kees Cook
#2 lore raw
Quoted 1 line · Kees Cook

The history and version links should be below the "---" line.

I have made the change.

Quoted 3 lines

But more importantly, please base your patch on the upstream tree, rather than on your v1 patch. :) (i.e. squash your v1 and v2 together).

I have squashed the two commits and shared v3 of the patch here:
https://lore.kernel.org/all/[email protected]/

Quoted 2 lines

-Kees

--
Abhinav