mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: sunran001@208suo.com
To: davem@davemloft.net
Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] sparc: add missing put_device()
Date: Tue, 18 Jul 2023 15:19:08 +0800	[thread overview]
Message-ID: <4a1fd666ef4700ec17d1be60debf016b@208suo.com> (raw)
In-Reply-To: <20230718071735.16312-1-xujianghui@cdjrlc.com>

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/of_device_common.c:23:1-7: ERROR: missing
put_device; call of_find_device_by_node on line 18, but without a
corresponding object release within this function.
./arch/sparc/kernel/of_device_common.c:36:1-7: ERROR: missing
put_device; call of_find_device_by_node on line 30, but without a
corresponding object release within this function.
./arch/sparc/kernel/of_device_common.c:50:1-7: ERROR: missing
put_device; call of_find_device_by_node on line 42, but without a
corresponding object release within this function.

Signed-off-by: Ran Sun <sunran001@208suo.com>
---
  arch/sparc/kernel/of_device_common.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/arch/sparc/kernel/of_device_common.c 
b/arch/sparc/kernel/of_device_common.c
index 60f86b837658..7851307de6d0 100644
--- a/arch/sparc/kernel/of_device_common.c
+++ b/arch/sparc/kernel/of_device_common.c
@@ -20,6 +20,7 @@ unsigned int irq_of_parse_and_map(struct device_node 
*node, int index)
      if (!op || index >= op->archdata.num_irqs)
          return 0;

+    put_device(op->dev);
      return op->archdata.irqs[index];
  }
  EXPORT_SYMBOL(irq_of_parse_and_map);
@@ -32,6 +33,7 @@ int of_address_to_resource(struct device_node *node, 
int index,
      if (!op || index >= op->num_resources)
          return -EINVAL;

+    put_device(op->dev);
      memcpy(r, &op->archdata.resource[index], sizeof(*r));
      return 0;
  }
@@ -45,6 +47,7 @@ void __iomem *of_iomap(struct device_node *node, int 
index)
      if (!op || index >= op->num_resources)
          return NULL;

+    put_device(op->dev);
      r = &op->archdata.resource[index];

      return of_ioremap(r, 0, resource_size(r), (char *) r->name);

       reply	other threads:[~2023-07-18  7:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230718071735.16312-1-xujianghui@cdjrlc.com>
2023-07-18  7:19 ` sunran001 [this message]
2023-07-18  8:45   ` Dmitry Baryshkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4a1fd666ef4700ec17d1be60debf016b@208suo.com \
    --to=sunran001@208suo.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sparclinux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®