mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arvind Yadav <arvind.yadav.cs@gmail.com>
To: mchehab@kernel.org, bp@alien8.de, tony.luck@intel.com
Cc: linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] EDAC: skx_edac: Handle return value of kasprintf
Date: Thu, 21 Sep 2017 13:23:13 +0530	[thread overview]
Message-ID: <1505980393-20307-4-git-send-email-arvind.yadav.cs@gmail.com> (raw)
In-Reply-To: <1505980393-20307-1-git-send-email-arvind.yadav.cs@gmail.com>

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

  parent reply	other threads:[~2017-09-21  7:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-21  7:53 [PATCH 0/3] EDAC: " Arvind Yadav
2017-09-21  7:53 ` [PATCH 1/3] EDAC: i7core: " Arvind Yadav
2017-09-21  7:53 ` [PATCH 2/3] EDAC: sb_edac: " Arvind Yadav
2017-09-21  7:53 ` Arvind Yadav [this message]
2017-09-21 10:19 ` [PATCH 0/3] EDAC: " Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1505980393-20307-4-git-send-email-arvind.yadav.cs@gmail.com \
    --to=arvind.yadav.cs@gmail.com \
    --cc=bp@alien8.de \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®