LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/powernv: add NULL check after kzalloc in opal_add_one_export
@ 2020-04-05  7:51 Qiujun Huang
  2020-04-05 10:13 ` Christophe Leroy
  0 siblings, 1 reply; 3+ messages in thread
From: Qiujun Huang @ 2020-04-05  7:51 UTC (permalink / raw)
  To: benh, paulus, mpe, tglx; +Cc: linuxppc-dev, linux-kernel, Qiujun Huang

Here needs a NULL check.

Issue found by coccinelle.

Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
---
 arch/powerpc/platforms/powernv/opal.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index 2b3dfd0b6cdd..09443ae3a86e 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -811,6 +811,11 @@ static int opal_add_one_export(struct kobject *parent, const char *export_name,
 		goto out;
 
 	attr = kzalloc(sizeof(*attr), GFP_KERNEL);
+	if (!attr) {
+		rc = -ENOMEM;
+		goto out;
+	}
+
 	name = kstrdup(export_name, GFP_KERNEL);
 	if (!name) {
 		rc = -ENOMEM;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc/powernv: add NULL check after kzalloc in opal_add_one_export
  2020-04-05  7:51 [PATCH] powerpc/powernv: add NULL check after kzalloc in opal_add_one_export Qiujun Huang
@ 2020-04-05 10:13 ` Christophe Leroy
  2020-04-05 10:21   ` Qiujun Huang
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe Leroy @ 2020-04-05 10:13 UTC (permalink / raw)
  To: Qiujun Huang, benh, paulus, mpe, tglx; +Cc: linuxppc-dev, linux-kernel



Le 05/04/2020 à 09:51, Qiujun Huang a écrit :
> Here needs a NULL check.
> 
> Issue found by coccinelle.
> 
> Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
> ---
>   arch/powerpc/platforms/powernv/opal.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
> index 2b3dfd0b6cdd..09443ae3a86e 100644
> --- a/arch/powerpc/platforms/powernv/opal.c
> +++ b/arch/powerpc/platforms/powernv/opal.c
> @@ -811,6 +811,11 @@ static int opal_add_one_export(struct kobject *parent, const char *export_name,
>   		goto out;
>   
>   	attr = kzalloc(sizeof(*attr), GFP_KERNEL);
> +	if (!attr) {
> +		rc = -ENOMEM;
> +		goto out;

You don't need to go to out:, there is nothing to do. You should do:

	if (!attr)
		return -ENOMEM;

> +	}
> +
>   	name = kstrdup(export_name, GFP_KERNEL);
>   	if (!name) {
>   		rc = -ENOMEM;
> 

Christophe

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc/powernv: add NULL check after kzalloc in opal_add_one_export
  2020-04-05 10:13 ` Christophe Leroy
@ 2020-04-05 10:21   ` Qiujun Huang
  0 siblings, 0 replies; 3+ messages in thread
From: Qiujun Huang @ 2020-04-05 10:21 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: tglx, paulus, linuxppc-dev, LKML

On Sun, Apr 5, 2020 at 6:13 PM Christophe Leroy <christophe.leroy@c-s.fr> wrote:
>
>
>
> Le 05/04/2020 à 09:51, Qiujun Huang a écrit :
> > Here needs a NULL check.
> >
> > Issue found by coccinelle.
> >
> > Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
> > ---
> >   arch/powerpc/platforms/powernv/opal.c | 5 +++++
> >   1 file changed, 5 insertions(+)
> >
> > diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
> > index 2b3dfd0b6cdd..09443ae3a86e 100644
> > --- a/arch/powerpc/platforms/powernv/opal.c
> > +++ b/arch/powerpc/platforms/powernv/opal.c
> > @@ -811,6 +811,11 @@ static int opal_add_one_export(struct kobject *parent, const char *export_name,
> >               goto out;
> >
> >       attr = kzalloc(sizeof(*attr), GFP_KERNEL);
> > +     if (!attr) {
> > +             rc = -ENOMEM;
> > +             goto out;
>
> You don't need to go to out:, there is nothing to do. You should do:
>
>         if (!attr)
>                 return -ENOMEM;

Yeah, I get that. Thanks.

>
> > +     }
> > +
> >       name = kstrdup(export_name, GFP_KERNEL);
> >       if (!name) {
> >               rc = -ENOMEM;
> >
>
> Christophe

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-05 10:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-05  7:51 [PATCH] powerpc/powernv: add NULL check after kzalloc in opal_add_one_export Qiujun Huang
2020-04-05 10:13 ` Christophe Leroy
2020-04-05 10:21   ` Qiujun Huang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox