lkml.org 
[lkml]   [2017]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/3] EDAC: skx_edac: Handle return value of kasprintf
Date
kasprintf() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.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
\
 
 \ /
  Last update: 2017-09-21 19:29    [W:0.100 / U:5.288 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site