]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
powerpc/pseries/dlpar: Fix a missing check in dlpar_parse_cc_property()
authorGen Zhang <blackgod016574@gmail.com>
Sun, 26 May 2019 02:42:40 +0000 (10:42 +0800)
committerMichael Ellerman <mpe@ellerman.id.au>
Sun, 2 Jun 2019 09:39:35 +0000 (19:39 +1000)
In dlpar_parse_cc_property(), 'prop->name' is allocated by kstrdup().
kstrdup() may return NULL, so it should be checked and handle error.
And prop should be freed if 'prop->name' is NULL.

Signed-off-by: Gen Zhang <blackgod016574@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/platforms/pseries/dlpar.c

index 17958043e7f7be29c17f90b369ab13842cef49ae..c852024044bb7dd7287b97a52d3681c31e89e6ba 100644 (file)
@@ -61,6 +61,10 @@ static struct property *dlpar_parse_cc_property(struct cc_workarea *ccwa)
 
        name = (char *)ccwa + be32_to_cpu(ccwa->name_offset);
        prop->name = kstrdup(name, GFP_KERNEL);
+       if (!prop->name) {
+               dlpar_free_cc_property(prop);
+               return NULL;
+       }
 
        prop->length = be32_to_cpu(ccwa->prop_length);
        value = (char *)ccwa + be32_to_cpu(ccwa->prop_offset);