powerpc/powernv: add NULL check after kzalloc in opal_add_one_export
PATCH 1/1 powerpc/powernv: add NULL check after kzalloc in opal_add_one_export
Here needs a NULL check.
Issue found by coccinelle.
--- arch/powerpc/platforms/powernv/opal.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/powerpc/platforms/powernv/opal.c +5 -0
@@ -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 ;
Signature · 1 line
2.17.1
Le 05/04/2020 à 09:51, Qiujun Huang a écrit :
Quoted 14 lines
Here needs a NULL check.
Issue found by coccinelle.
Signed-off-by Qiujun Huang <[email protected]>--- arch/powerpc/platforms/powernv/opal.c | 5 +++++ 1 file changed, 5 insertions(+)arch/powerpc/platforms/powernv/opal.c +0
-0
arch/powerpc/platforms/powernv/opal.c static int opal_add_one_export(struct kobject *parent, const char *export_name, · line 816
Quoted 6 lines
arch/powerpc/platforms/powernv/opal.c +3
-0@@ -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;
arch/powerpc/platforms/powernv/opal.c static int opal_add_one_export(struct kobject *parent, const char *export_name, · line 821
Quoted 6 lines
arch/powerpc/platforms/powernv/opal.c +2
-0+ } + name =kstrdup (export_name,GFP_KERNEL );if (!name) { rc = -ENOMEM ;
Christophe
Quoted 27 lines · Christophe Leroy
Quoted 14 lines · Qiujun Huang
Here needs a NULL check.
Issue found by coccinelle.
Signed-off-by Qiujun Huang <[email protected]>--- arch/powerpc/platforms/powernv/opal.c | 5 +++++ 1 file changed, 5 insertions(+)arch/powerpc/platforms/powernv/opal.c +0
-0arch/powerpc/platforms/powernv/opal.c static int opal_add_one_export(struct kobject *parent, const char *export_name, · line 816
Quoted 6 lines
arch/powerpc/platforms/powernv/opal.c +3
-0@@ -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:
Quoted 2 lines
if (!attr)
return -ENOMEM;Yeah, I get that. Thanks.
Quoted 9 lines
arch/powerpc/platforms/powernv/opal.c static int opal_add_one_export(struct kobject *parent, const char *export_name, · line 821
Quoted 7 lines
arch/powerpc/platforms/powernv/opal.c +2
-0+ } + name =kstrdup (export_name,GFP_KERNEL );if (!name) { rc = -ENOMEM ;Christophe