powerpc/pseries: Fix possible leaked device node reference
authorNathan Fontenot <nfont@linux.vnet.ibm.com>
Thu, 30 Apr 2015 01:44:58 +0000 (20:44 -0500)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 11 May 2015 06:58:20 +0000 (16:58 +1000)
Failure return from dlpar_configure_connector when dlpar adding cpus
results in leaking references to the cpus parent device node. Move the
call to of_node_put() prior to checking the result of
dlpar_configure_connector.

Fixes: 8d5ff320766f ("powerpc/pseries: Make dlpar_configure_connector parent node aware")

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/platforms/pseries/dlpar.c

index 019d34aaf054bc843d6a2d5ac531e9207e6c42ab..47d9cebe7159edb2d5d72a3167a89d928dbaa5dc 100644 (file)
@@ -421,11 +421,10 @@ static ssize_t dlpar_cpu_probe(const char *buf, size_t count)
                return -ENODEV;
 
        dn = dlpar_configure_connector(cpu_to_be32(drc_index), parent);
+       of_node_put(parent);
        if (!dn)
                return -EINVAL;
 
-       of_node_put(parent);
-
        rc = dlpar_attach_node(dn);
        if (rc) {
                dlpar_release_drc(drc_index);