Skip to contentSkip to conversation

sparc: kernel: add missing put_device()

PATCH In review [email protected] 2 participants 2 messages Jul 18, 2023 1 message not in the archive SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 sparc: kernel: add missing put_device()

The of_find_device_by_node() takes a reference to the underlying device structure, we should release that reference.

Detected by coccinelle with the following ERRORS:
./arch/sparc/kernel/pci_psycho.c:308:2-8: ERROR: missing put_device; call of_find_device_by_node on line 290, but without a corresponding object release within this function. ./arch/sparc/kernel/pci_psycho.c:350:0-1: ERROR: missing put_device; call of_find_device_by_node on line 290, but without a corresponding object release within this function.

---
 arch/sparc/kernel/pci_psycho.c | 2 ++
 1 file changed, 2 insertions(+)
arch/sparc/kernel/pci_psycho.c +2 -0
index f413371da387..45f8370bbfad 100644
@@ -305,6 +305,7 @@ static void psycho_register_error_handlers(struct pci_pbm_info *pbm)
      */
 
     if (op->archdata.num_irqs < 6)
+        put_device(op->dev);
         return;
 
     /* We really mean to ignore the return result here.  Two
@@ -347,6 +348,7 @@ static void psycho_register_error_handlers(struct pci_pbm_info *pbm)
         PSYCHO_PCICTRL_EEN);
     tmp &= ~(PSYCHO_PCICTRL_SBH_INT);
     upa_writeq(tmp, base + PSYCHO_PCIB_CTRL);
+    put_device(op->dev);
 }
 
 /* PSYCHO boot time probing and initialization. */
#2 lore raw

Hi Ran Sun,

Quoted 21 lines · On Tue, Jul 18, 2023 at 03:26:31PM +0800, [email protected] wrote:

The of_find_device_by_node() takes a reference to the underlying device structure, we should release that reference.

Detected by coccinelle with the following ERRORS:
./arch/sparc/kernel/pci_psycho.c:308:2-8: ERROR: missing put_device; call of_find_device_by_node on line 290, but without a corresponding object release within this function. ./arch/sparc/kernel/pci_psycho.c:350:0-1: ERROR: missing put_device; call of_find_device_by_node on line 290, but without a corresponding object release within this function.

---
 arch/sparc/kernel/pci_psycho.c | 2 ++
 1 file changed, 2 insertions(+)
arch/sparc/kernel/pci_psycho.c +0 -0
index f413371da387..45f8370bbfad 100644

arch/sparc/kernel/pci_psycho.c static void psycho_register_error_handlers(struct · line 310

Quoted 6 lines
arch/sparc/kernel/pci_psycho.c +1 -0
@@ -305,6 +305,7 @@ static void psycho_register_error_handlers(struct
 pci_pbm_info *pbm)
      */
 
     if (op->archdata.num_irqs < 6)
+        put_device(op->dev);
         return;

Missing {}

Sam

Quoted 11 lines
arch/sparc/kernel/pci_psycho.c +1 -0
     /* We really mean to ignore the return result here.  Two
@@ -347,6 +348,7 @@ static void psycho_register_error_handlers(struct
 pci_pbm_info *pbm)
         PSYCHO_PCICTRL_EEN);
     tmp &= ~(PSYCHO_PCICTRL_SBH_INT);
     upa_writeq(tmp, base + PSYCHO_PCIB_CTRL);
+    put_device(op->dev);
 }
 

/* PSYCHO boot time probing and initialization. */