Skip to contentSkip to conversation

PCI: iproc: Use __free(device_node) in iproc_pcie_msi_enable()

PATCH Superseded Fuad Tabba 4 participants 5 messages Sep 22 – Sep 23

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Fuad Tabba

author
#0 lore raw

PATCH 1/1 PCI: iproc: Use __free(device_node) in iproc_pcie_msi_enable()

Declare msi_node with __free(device_node) and drop the out_put_node label and its goto: the scoped cleanup puts the MSI controller node on every return, as the label did.

No functional change intended.

---
 drivers/pci/controller/pcie-iproc.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/pci/controller/pcie-iproc.c +3 -7
index afb3aa38ac6bb..b4f4e6e1d4b41 100644
@@ -1338,7 +1338,7 @@ static int iproc_pcie_msi_steer(struct iproc_pcie *pcie,
 
 static int iproc_pcie_msi_enable(struct iproc_pcie *pcie)
 {
-	struct device_node *msi_node = NULL;
+	struct device_node *msi_node __free(device_node) = NULL;
 	int ret;
 
 	/*
@@ -1357,18 +1357,14 @@ static int iproc_pcie_msi_enable(struct iproc_pcie *pcie)
 	if (pcie->need_msi_steer) {
 		ret = iproc_pcie_msi_steer(pcie, msi_node);
 		if (ret)
-			goto out_put_node;
+			return ret;
 	}
 
 	/*
 	 * If another MSI controller is being used, the call below should fail
 	 * but that is okay
 	 */
-	ret = iproc_msi_init(pcie, msi_node);
-
-out_put_node:
-	of_node_put(msi_node);
-	return ret;
+	return iproc_msi_init(pcie, msi_node);
 }
 
 static void iproc_pcie_msi_disable(struct iproc_pcie *pcie)

base-commit: fd73f4a6659897191fa0d40695fe370925dd3780

Signature · 1 line
2.39.5
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines

Declare msi_node with __free(device_node) and drop the out_put_node label and its goto: the scoped cleanup puts the MSI controller node on every return, as the label did.

No functional change intended.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Reviewed-by on v1 1/1
#2 lore raw
In reply to Fuad Tabba
Quoted 4 lines · Fuad Tabba

Declare msi_node with __free(device_node) and drop the out_put_node label and its goto: the scoped cleanup puts the MSI controller node on every return, as the label did.

Quoted 8 lines

No functional change intended.

---
  drivers/pci/controller/pcie-iproc.c | 10 +++-------
  1 file changed, 3 insertions(+), 7 deletions(-)

This is nice.

Thank you.

#3 lore raw
In reply to Fuad Tabba
Quoted 9 lines · On Tue, 22 Sep 2026 22:08:39 +0100 Fuad Tabba <[email protected]> wrote:

Declare msi_node with __free(device_node) and drop the out_put_node label and its goto: the scoped cleanup puts the MSI controller node on every return, as the label did.

No functional change intended.

Hi Fuad,

See the guidance notes in cleanup.h. Linus has stated a couple
of times that he really never wants to see = NULL pattern miles from where it is allocated. Best you can do here is shift
it down to immediately before of_msi_xlate(). It is fine to declare variables with destructors like this inline (i.e. not at top of function).

Admittedly if the scope shown here had gone a few lines further this would look less bad!

Quoted 40 lines
---
 drivers/pci/controller/pcie-iproc.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/pci/controller/pcie-iproc.c +3 -7
index afb3aa38ac6bb..b4f4e6e1d4b41 100644
@@ -1338,7 +1338,7 @@ static int iproc_pcie_msi_steer(struct iproc_pcie *pcie,
 
 static int iproc_pcie_msi_enable(struct iproc_pcie *pcie)
 {
-	struct device_node *msi_node = NULL;
+	struct device_node *msi_node __free(device_node) = NULL;
 	int ret;
 
 	/*
@@ -1357,18 +1357,14 @@ static int iproc_pcie_msi_enable(struct iproc_pcie *pcie)
 	if (pcie->need_msi_steer) {
 		ret = iproc_pcie_msi_steer(pcie, msi_node);
 		if (ret)
-			goto out_put_node;
+			return ret;
 	}
 
 	/*
 	 * If another MSI controller is being used, the call below should fail
 	 * but that is okay
 	 */
-	ret = iproc_msi_init(pcie, msi_node);
-
-out_put_node:
-	of_node_put(msi_node);
-	return ret;
+	return iproc_msi_init(pcie, msi_node);
 }
 
 static void iproc_pcie_msi_disable(struct iproc_pcie *pcie)

base-commit: fd73f4a6659897191fa0d40695fe370925dd3780

author
#4 lore raw

Hi Jonathan,

On Wed, 23 Sept 2026 at 17:34, Jonathan Cameron
<[email protected]> wrote:
[...]

Quoted 10 lines

Hi Fuad,

See the guidance notes in cleanup.h. Linus has stated a couple
of times that he really never wants to see = NULL pattern miles from where it is allocated. Best you can do here is shift
it down to immediately before of_msi_xlate(). It is fine to declare variables with destructors like this inline (i.e. not at top of function).

Admittedly if the scope shown here had gone a few lines further this would look less bad!

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

Cheers,
/fuad

Quoted 43 lines
Quoted 42 lines

---
 drivers/pci/controller/pcie-iproc.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/pci/controller/pcie-iproc.c +3 -7
index afb3aa38ac6bb..b4f4e6e1d4b41 100644
@@ -1338,7 +1338,7 @@ static int iproc_pcie_msi_steer(struct iproc_pcie *pcie,
 
 static int iproc_pcie_msi_enable(struct iproc_pcie *pcie)
 {
-     struct device_node *msi_node = NULL;
+     struct device_node *msi_node __free(device_node) = NULL;
      int ret;
 
      /*
@@ -1357,18 +1357,14 @@ static int iproc_pcie_msi_enable(struct iproc_pcie *pcie)
      if (pcie->need_msi_steer) {
              ret = iproc_pcie_msi_steer(pcie, msi_node);
              if (ret)
-                     goto out_put_node;
+                     return ret;
      }
 
      /*
       * If another MSI controller is being used, the call below should fail
       * but that is okay
       */
-     ret = iproc_msi_init(pcie, msi_node);
-
-out_put_node:
-     of_node_put(msi_node);
-     return ret;
+     return iproc_msi_init(pcie, msi_node);
 }
 
 static void iproc_pcie_msi_disable(struct iproc_pcie *pcie)

base-commit: fd73f4a6659897191fa0d40695fe370925dd3780