From: Miaoqian Lin <linmq006@gmail.com>
To: Frederic Barrat <fbarrat@linux.ibm.com>,
Andrew Donnellan <ajd@linux.ibm.com>,
Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Christophe Lombard <clombard@linux.vnet.ibm.com>,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Cc: linmq006@gmail.com
Subject: [PATCH] cxl: Fix refcount leak in cxl_calc_capp_routing
Date: Sun, 5 Jun 2022 10:00:38 +0400 [thread overview]
Message-ID: <20220605060038.62217-1-linmq006@gmail.com> (raw)
of_get_next_parent() returns a node pointer with refcount incremented,
we should use of_node_put() on it when not need anymore.
This function only calls of_node_put() in normal path,
missing it in the error path.
Add missing of_node_put() to avoid refcount leak.
Fixes: f24be42aab37 ("cxl: Add psl9 specific code")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
drivers/misc/cxl/pci.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index 3de0aea62ade..62385a529d86 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -387,6 +387,7 @@ int cxl_calc_capp_routing(struct pci_dev *dev, u64 *chipid,
rc = get_phb_index(np, phb_index);
if (rc) {
pr_err("cxl: invalid phb index\n");
+ of_node_put(np);
return rc;
}
--
2.25.1
next reply other threads:[~2022-06-05 6:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-05 6:00 Miaoqian Lin [this message]
2022-06-07 9:05 ` [PATCH] cxl: Fix refcount leak in cxl_calc_capp_routing Frederic Barrat
2022-06-14 10:12 ` Andrew Donnellan
2022-11-14 12:42 ` Christophe Leroy
2022-11-22 5:39 ` Andrew Donnellan
2022-11-30 9:23 ` Michael Ellerman
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=20220605060038.62217-1-linmq006@gmail.com \
--to=linmq006@gmail.com \
--cc=ajd@linux.ibm.com \
--cc=arnd@arndb.de \
--cc=clombard@linux.vnet.ibm.com \
--cc=fbarrat@linux.ibm.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
/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;
as well as URLs for NNTP newsgroup(s).