[PATCH 1/3] EDAC: i7core: Handle return value of kasprintf
From: Arvind Yadav
Date: Thu Sep 21 2017 - 03:54:41 EST
kasprintf() can fail here and we must check its return value.
Signed-off-by: Arvind Yadav <arvind.yadav.cs@xxxxxxxxx>
---
drivers/edac/i7core_edac.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index c16c3b9..054f361 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -2161,6 +2161,11 @@ static int i7core_register_mci(struct i7core_dev *i7core_dev)
mci->mod_name = "i7core_edac.c";
mci->ctl_name = kasprintf(GFP_KERNEL, "i7 core #%d",
i7core_dev->socket);
+ if (!mci->ctl_name) {
+ rc = -ENOMEM;
+ goto fail1;
+ }
+
mci->dev_name = pci_name(i7core_dev->pdev[0]);
mci->ctl_page_to_phys = NULL;
@@ -2214,6 +2219,7 @@ static int i7core_register_mci(struct i7core_dev *i7core_dev)
fail0:
kfree(mci->ctl_name);
+fail1:
edac_mc_free(mci);
i7core_dev->mci = NULL;
return rc;
--
1.9.1