Skip to contentSkip to conversation

sparc: pci: Fix memory leak in pci_bus_slot_names()

PATCH In review Salah Triki 2 participants 3 messages Apr 7, 2025 – Apr 9, 2025 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sparc: pci: Fix memory leak in pci_bus_slot_names()

prop is a local pointer in pci_bus_slot_names(). It is initialized by calling of_get_property() so the caller must free prop when done using it.

---
 arch/sparc/kernel/pci.c | 2 ++
 1 file changed, 2 insertions(+)
arch/sparc/kernel/pci.c +2 -0
index ddac216a2aff..fa0da8f45723 100644
@@ -971,6 +971,8 @@ static void pci_bus_slot_names(struct device_node *node, struct pci_bus *bus)
 		mask &= ~this_bit;
 		i++;
 	}
+
+	kfree(prop);
 }
 
 static int __init of_pci_slot_init(void)
Signature · 1 line
2.43.0
#1 lore raw

Le 07/04/2025 à 13:06, Salah Triki a écrit :

Quoted 3 lines

prop is a local pointer in pci_bus_slot_names(). It is initialized by calling of_get_property() so the caller must free prop when done using it.

Hi,

can you elaborate why?

It does not look needed to me, and the places using of_get_property() that I've checked don't have such a kfree().

CJ

Quoted 19 lines
---
  arch/sparc/kernel/pci.c | 2 ++
  1 file changed, 2 insertions(+)
arch/sparc/kernel/pci.c +2 -0
index ddac216a2aff..fa0da8f45723 100644
@@ -971,6 +971,8 @@ static void pci_bus_slot_names(struct device_node *node, struct pci_bus *bus)
  		mask &= ~this_bit;
  		i++;
  	}
+
+	kfree(prop);
  }
 
  static int __init of_pci_slot_init(void)
#2 lore raw
Quoted 5 lines · Christophe JAILLET

Le 07/04/2025 à 13:06, Salah Triki a écrit :

Quoted 3 lines

prop is a local pointer in pci_bus_slot_names(). It is initialized by calling of_get_property() so the caller must free prop when done using it.

Quoted 8 lines

Hi,

can you elaborate why?

It does not look needed to me, and the places using of_get_property() that I've checked don't have such a kfree().

CJ

Hi,

Sorry for disturbing, I was wrong about that.

ST

Quoted 20 lines
Quoted 19 lines
---
  arch/sparc/kernel/pci.c | 2 ++
  1 file changed, 2 insertions(+)
arch/sparc/kernel/pci.c +2 -0
index ddac216a2aff..fa0da8f45723 100644
@@ -971,6 +971,8 @@ static void pci_bus_slot_names(struct device_node *node, struct pci_bus *bus)
  		mask &= ~this_bit;
  		i++;
  	}
+
+	kfree(prop);
  }
  static int __init of_pci_slot_init(void)