diff mbox series

[v2,2/2] crypto: nx: Hold the reference returned by of_find_compatible_node

Message ID 20220630083657.206122-2-windhl@126.com (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series [v2,1/2] crypto: amcc: Hold the reference returned by of_find_compatible_node | expand

Commit Message

Liang He June 30, 2022, 8:36 a.m. UTC
In nx842_pseries_init(), we should hold the reference returned by
of_find_compatible_node() and use it to call of_node_put to keep
refcount balance.

Signed-off-by: Liang He <windhl@126.com>
---
 changelog:

 v2: split v1 into two commits
 v1: fix bugs in two directories (amcc,nx) of crypto

 v1-link: https://lore.kernel.org/all/20220621073742.4081013-1-windhl@126.com/


 drivers/crypto/nx/nx-common-pseries.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/crypto/nx/nx-common-pseries.c b/drivers/crypto/nx/nx-common-pseries.c
index 7584a34ba88c..3ea334b7f820 100644
--- a/drivers/crypto/nx/nx-common-pseries.c
+++ b/drivers/crypto/nx/nx-common-pseries.c
@@ -1208,10 +1208,13 @@  static struct vio_driver nx842_vio_driver = {
 static int __init nx842_pseries_init(void)
 {
 	struct nx842_devdata *new_devdata;
+	struct device_node *np;
 	int ret;
 
-	if (!of_find_compatible_node(NULL, NULL, "ibm,compression"))
+	np = of_find_compatible_node(NULL, NULL, "ibm,compression");
+	if (!np)
 		return -ENODEV;
+	of_node_put(np);
 
 	RCU_INIT_POINTER(devdata, NULL);
 	new_devdata = kzalloc(sizeof(*new_devdata), GFP_KERNEL);