mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: liubin001@208suo.com
To: tglx@linutronix.de, maz@kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: Fwd: [PATCH] irqchip:Use the "put_device" function to release the memory after calling the of_find_device_by_node function.
Date: Fri, 14 Jul 2023 11:43:28 +0800	[thread overview]
Message-ID: <66d48e6ce0db4f89737172a2963195a9@208suo.com> (raw)
In-Reply-To: <tencent_C69953B5D14B406504315830D8DE7112EC0A@qq.com>

Write the put_device function before return

Signed-off-by: Liu Bin <liubin001@208suo.com>
---
  drivers/irqchip/irq-renesas-rzg2l.c | 10 +++++++++-
  1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-renesas-rzg2l.c 
b/drivers/irqchip/irq-renesas-rzg2l.c
index 4bbfa2b0a4df..a9d75135ba24 100644
--- a/drivers/irqchip/irq-renesas-rzg2l.c
+++ b/drivers/irqchip/irq-renesas-rzg2l.c
@@ -325,35 +325,42 @@ static int rzg2l_irqc_init(struct device_node 
*node, struct device_node *parent)

      pdev = of_find_device_by_node(node);
      if (!pdev)
+        put_device(pdev);
          return -ENODEV;

      parent_domain = irq_find_host(parent);
      if (!parent_domain) {
          dev_err(&pdev->dev, "cannot find parent domain\n");
+        put_device(pdev);
          return -ENODEV;
      }

      priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
      if (!priv)
+        put_device(pdev);
          return -ENOMEM;

      priv->base = devm_of_iomap(&pdev->dev, pdev->dev.of_node, 0, NULL);
      if (IS_ERR(priv->base))
+        put_device(pdev);
          return PTR_ERR(priv->base);

      ret = rzg2l_irqc_parse_interrupts(priv, node);
      if (ret) {
          dev_err(&pdev->dev, "cannot parse interrupts: %d\n", ret);
+        put_device(pdev);
          return ret;
      }

      resetn = devm_reset_control_get_exclusive(&pdev->dev, NULL);
      if (IS_ERR(resetn))
+        put_device(pdev);
          return PTR_ERR(resetn);

      ret = reset_control_deassert(resetn);
      if (ret) {
          dev_err(&pdev->dev, "failed to deassert resetn pin, %d\n", 
ret);
+        put_device(pdev);
          return ret;
      }

@@ -374,7 +381,7 @@ static int rzg2l_irqc_init(struct device_node *node, 
struct device_node *parent)
          ret = -ENOMEM;
          goto pm_put;
      }
-
+    put_device(pdev);
      return 0;

  pm_put:
@@ -382,6 +389,7 @@ static int rzg2l_irqc_init(struct device_node *node, 
struct device_node *parent)
  pm_disable:
      pm_runtime_disable(&pdev->dev);
      reset_control_assert(resetn);
+    put_device(pdev);
      return ret;
  }

       reply	other threads:[~2023-07-14  3:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <tencent_C69953B5D14B406504315830D8DE7112EC0A@qq.com>
2023-07-14  3:43 ` liubin001 [this message]
2023-07-14  8:06   ` Marc Zyngier

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=66d48e6ce0db4f89737172a2963195a9@208suo.com \
    --to=liubin001@208suo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=tglx@linutronix.de \
    /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®