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 1/3] EDAC: i7core: 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/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
\
 
 \ /
  Last update: 2017-09-21 19:29    [W:0.099 / U:0.444 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site