crypto: nx - Hold the reference returned by of_find_compatible_node
authorLiang He <windhl@126.com>
Thu, 30 Jun 2022 08:36:57 +0000 (16:36 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 8 Jul 2022 07:21:16 +0000 (15:21 +0800)
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>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/nx/nx-common-pseries.c

index 7584a34..3ea334b 100644 (file)
@@ -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);