powerpc/pseries/dlpar: Eliminate use after free
authorJulia Lawall <julia@diku.dk>
Fri, 2 Apr 2010 02:47:13 +0000 (02:47 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 7 Apr 2010 08:00:41 +0000 (18:00 +1000)
dlpar_free_cc_nodes frees its argument, so dlpar_online_cpu should not be
called on the same value.  Skip over the call to dlpar_online_cpu by
jumping directly to out.

A simplified version of the semantic patch that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression E,E2;
@@

dlpar_free_cc_nodes(E)
...
(
  E = E2
|
* E
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/platforms/pseries/dlpar.c

index e1682bc..1540a41 100644 (file)
@@ -433,6 +433,7 @@ static ssize_t dlpar_cpu_probe(const char *buf, size_t count)
        if (rc) {
                dlpar_release_drc(drc_index);
                dlpar_free_cc_nodes(dn);
        if (rc) {
                dlpar_release_drc(drc_index);
                dlpar_free_cc_nodes(dn);
+               goto out;
        }
 
        rc = dlpar_online_cpu(dn);
        }
 
        rc = dlpar_online_cpu(dn);