* [PATCH] dlpar: Fix a missing-check bug in dlpar_parse_cc_property()
@ 2019-05-26 2:42 Gen Zhang
2019-05-28 16:38 ` Nathan Lynch
2019-06-03 12:32 ` Michael Ellerman
0 siblings, 2 replies; 4+ messages in thread
From: Gen Zhang @ 2019-05-26 2:42 UTC (permalink / raw)
To: benh, paulus; +Cc: nfont, linuxppc-dev, linux-kernel
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>
---
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;
+ }
prop->length = be32_to_cpu(ccwa->prop_length);
value = (char *)ccwa + be32_to_cpu(ccwa->prop_offset);
---
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] dlpar: Fix a missing-check bug in dlpar_parse_cc_property()
2019-05-26 2:42 [PATCH] dlpar: Fix a missing-check bug in dlpar_parse_cc_property() Gen Zhang
@ 2019-05-28 16:38 ` Nathan Lynch
2019-06-03 12:32 ` Michael Ellerman
1 sibling, 0 replies; 4+ messages in thread
From: Nathan Lynch @ 2019-05-28 16:38 UTC (permalink / raw)
To: Gen Zhang, benh, paulus; +Cc: linuxppc-dev, linux-kernel
Gen Zhang <blackgod016574@gmail.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@gmail.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@linux.ibm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] dlpar: Fix a missing-check bug in dlpar_parse_cc_property()
2019-05-26 2:42 [PATCH] dlpar: Fix a missing-check bug in dlpar_parse_cc_property() Gen Zhang
2019-05-28 16:38 ` Nathan Lynch
@ 2019-06-03 12:32 ` Michael Ellerman
1 sibling, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2019-06-03 12:32 UTC (permalink / raw)
To: Gen Zhang, benh, paulus; +Cc: nfont, linuxppc-dev, linux-kernel
On Sun, 2019-05-26 at 02:42:40 UTC, Gen Zhang wrote:
> 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>
> Acked-by: Nathan Lynch <nathanl@linux.ibm.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/efa9ace68e487ddd29c2b4d6dd232421
cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] dlpar: Fix a missing-check bug in dlpar_parse_cc_property()
@ 2019-05-30 0:58 Gen Zhang
0 siblings, 0 replies; 4+ messages in thread
From: Gen Zhang @ 2019-05-30 0:58 UTC (permalink / raw)
To: benh, paulus, mpe; +Cc: linuxppc-dev, linux-kernel
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>
Acked-by: Nathan Lynch <nathanl@linux.ibm.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;
+ }
prop->length = be32_to_cpu(ccwa->prop_length);
value = (char *)ccwa + be32_to_cpu(ccwa->prop_offset);
---
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-06-03 12:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-26 2:42 [PATCH] dlpar: Fix a missing-check bug in dlpar_parse_cc_property() Gen Zhang
2019-05-28 16:38 ` Nathan Lynch
2019-06-03 12:32 ` Michael Ellerman
2019-05-30 0:58 Gen Zhang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.