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

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