sparc: pci: Fix memory leak in pci_bus_slot_names()
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
@@ -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
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 callingof_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
Signed-off-by Salah Triki <[email protected]>--- arch/sparc/kernel/pci.c | 2 ++ 1 file changed, 2 insertions(+)arch/sparc/kernel/pci.c +2
-0@@ -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 )
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 callingof_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 akfree().CJ
Hi,
Sorry for disturbing, I was wrong about that.
ST
Quoted 20 lines
Quoted 19 lines
Signed-off-by Salah Triki <[email protected]>--- arch/sparc/kernel/pci.c | 2 ++ 1 file changed, 2 insertions(+)arch/sparc/kernel/pci.c +2
-0@@ -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 )