[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1505980393-20307-4-git-send-email-arvind.yadav.cs@gmail.com>
Date: Thu, 21 Sep 2017 13:23:13 +0530
From: Arvind Yadav <arvind.yadav.cs@...il.com>
To: mchehab@...nel.org, bp@...en8.de, tony.luck@...el.com
Cc: linux-edac@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 3/3] EDAC: skx_edac: Handle return value of kasprintf
kasprintf() can fail here and we must check its return value.
Signed-off-by: Arvind Yadav <arvind.yadav.cs@...il.com>
---
drivers/edac/skx_edac.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/edac/skx_edac.c b/drivers/edac/skx_edac.c
index 16dea97..a7b25bb 100644
--- a/drivers/edac/skx_edac.c
+++ b/drivers/edac/skx_edac.c
@@ -466,6 +466,11 @@ static int skx_register_mci(struct skx_imc *imc)
mci->ctl_name = kasprintf(GFP_KERNEL, "Skylake Socket#%d IMC#%d",
imc->node_id, imc->lmc);
+ if (!mci->ctl_name) {
+ rc = -ENOMEM;
+ goto fail0;
+ }
+
mci->mtype_cap = MEM_FLAG_DDR4;
mci->edac_ctl_cap = EDAC_FLAG_NONE;
mci->edac_cap = EDAC_FLAG_NONE;
@@ -491,6 +496,7 @@ static int skx_register_mci(struct skx_imc *imc)
fail:
kfree(mci->ctl_name);
+fail0:
edac_mc_free(mci);
imc->mci = NULL;
return rc;
--
1.9.1
Powered by blists - more mailing lists