Skip to contentSkip to conversation

check the kzalloc return value

PATCH In review Denis Kirjanov 2 participants 3 messages Oct 22, 2012 – Oct 23, 2012 EDAC-core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 check the kzalloc return value

---
 drivers/edac/edac_mc_sysfs.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/edac/edac_mc_sysfs.c +2 -1
index ed0bc07..55ce016 100644
@@ -1128,7 +1128,8 @@ int __init edac_mc_sysfs_init(void)
 	}
 
 	mci_pdev = kzalloc(sizeof(*mci_pdev), GFP_KERNEL);
-
+	if (!mci_pdev)
+		return -ENOMEM;
 	mci_pdev->bus = edac_subsys;
 	mci_pdev->type = &mc_attr_type;
 	device_initialize(mci_pdev);
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 1 line · Denis Kirjanov

Needs a commit message.

Quoted 10 lines
---
 drivers/edac/edac_mc_sysfs.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/edac/edac_mc_sysfs.c +0 -0
index ed0bc07..55ce016 100644

drivers/edac/edac_mc_sysfs.c int __init edac_mc_sysfs_init(void) · line 1132

Quoted 6 lines
drivers/edac/edac_mc_sysfs.c +2 -1
@@ -1128,7 +1128,8 @@ int __init edac_mc_sysfs_init(void)
 	}
 
 	mci_pdev = kzalloc(sizeof(*mci_pdev), GFP_KERNEL);
-
+	if (!mci_pdev)
+		return -ENOMEM;

This either needs to do

	edac_put_sysfs_subsys();

on the error-out path.

drivers/edac/edac_mc_sysfs.c int __init edac_mc_sysfs_init(void) · line 1135

Quoted 3 lines
drivers/edac/edac_mc_sysfs.c +0 -0
 	mci_pdev->bus = edac_subsys;
 	mci_pdev->type = &mc_attr_type;
 	device_initialize(mci_pdev);

Thanks.

Signature · 8 lines
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551
#2 lore raw

I'll resubmit a new patch.

Thanks!

Quoted 44 lines · Borislav Petkov
Quoted 1 line · Denis Kirjanov

Needs a commit message.

Quoted 10 lines
---
 drivers/edac/edac_mc_sysfs.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/edac/edac_mc_sysfs.c +0 -0
index ed0bc07..55ce016 100644

drivers/edac/edac_mc_sysfs.c int __init edac_mc_sysfs_init(void) · line 1132

Quoted 6 lines
drivers/edac/edac_mc_sysfs.c +2 -1
@@ -1128,7 +1128,8 @@ int __init edac_mc_sysfs_init(void)
 	}
 
 	mci_pdev = kzalloc(sizeof(*mci_pdev), GFP_KERNEL);
-
+	if (!mci_pdev)
+		return -ENOMEM;

This either needs to do

	edac_put_sysfs_subsys();

on the error-out path.

drivers/edac/edac_mc_sysfs.c int __init edac_mc_sysfs_init(void) · line 1135

Quoted 3 lines
drivers/edac/edac_mc_sysfs.c +0 -0
 	mci_pdev->bus = edac_subsys;
 	mci_pdev->type = &mc_attr_type;
 	device_initialize(mci_pdev);

Thanks.

--
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551

Signature · 2 lines
Regards,
Denis