diff options
author | Gen Zhang <blackgod016574@gmail.com> | 2019-05-26 10:42:40 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-12-05 15:27:10 +0100 |
commit | 27cb5fbc84ed4d97a4bbcab04fb186705bac303e (patch) | |
tree | 3c629b0df5de9f82ec49715b490b1a972ee07088 /arch | |
parent | e22387d2d7767305c3109eda585e84472dc2a8a0 (diff) | |
download | linux-stable-27cb5fbc84ed4d97a4bbcab04fb186705bac303e.tar.gz linux-stable-27cb5fbc84ed4d97a4bbcab04fb186705bac303e.tar.bz2 linux-stable-27cb5fbc84ed4d97a4bbcab04fb186705bac303e.zip |
powerpc/pseries/dlpar: Fix a missing check in dlpar_parse_cc_property()
[ Upstream commit efa9ace68e487ddd29c2b4d6dd23242158f1f607 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/platforms/pseries/dlpar.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c index a8efed3b4691..551ba5b35df9 100644 --- a/arch/powerpc/platforms/pseries/dlpar.c +++ b/arch/powerpc/platforms/pseries/dlpar.c @@ -55,6 +55,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); |