[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <87blzm4jqj.fsf@linux.ibm.com>
Date: Tue, 28 May 2019 11:38:44 -0500
From: Nathan Lynch <nathanl@...ux.ibm.com>
To: Gen Zhang <blackgod016574@...il.com>, benh@...nel.crashing.org,
paulus@...ba.org
Cc: linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] dlpar: Fix a missing-check bug in dlpar_parse_cc_property()
Gen Zhang <blackgod016574@...il.com> writes:
> 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@...il.com>
> ---
> diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
> index 1795804..c852024 100644
> --- a/arch/powerpc/platforms/pseries/dlpar.c
> +++ b/arch/powerpc/platforms/pseries/dlpar.c
> @@ -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;
> + }
Acked-by: Nathan Lynch <nathanl@...ux.ibm.com>
Powered by blists - more mailing lists