Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751925AbdIUHyV (ORCPT ); Thu, 21 Sep 2017 03:54:21 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33784 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751840AbdIUHyR (ORCPT ); Thu, 21 Sep 2017 03:54:17 -0400 X-Google-Smtp-Source: AOwi7QCPmI8jMnHc2zgMy4SywAM4qN1GZS/pz742tKaduTUUNqMQrZR8H7dEnAOVRAnCmcwgtZBCDw== From: Arvind Yadav To: mchehab@kernel.org, bp@alien8.de, tony.luck@intel.com Cc: linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] EDAC: i7core: Handle return value of kasprintf Date: Thu, 21 Sep 2017 13:23:11 +0530 Message-Id: <1505980393-20307-2-git-send-email-arvind.yadav.cs@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1505980393-20307-1-git-send-email-arvind.yadav.cs@gmail.com> References: <1505980393-20307-1-git-send-email-arvind.yadav.cs@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 905 Lines: 33 kasprintf() can fail here and we must check its return value. Signed-off-by: Arvind Yadav --- 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