Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751958AbdIUHyZ (ORCPT ); Thu, 21 Sep 2017 03:54:25 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:35646 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751840AbdIUHyV (ORCPT ); Thu, 21 Sep 2017 03:54:21 -0400 X-Google-Smtp-Source: AOwi7QDniiL/ydTE7hx0d75d5/y6xMIXjcXDXw0kHfsy2zhD2XBzxdq1axSdj6T9EwJ98aAG9jq58Q== 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 3/3] EDAC: skx_edac: Handle return value of kasprintf Date: Thu, 21 Sep 2017 13:23:13 +0530 Message-Id: <1505980393-20307-4-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: 859 Lines: 33 kasprintf() can fail here and we must check its return value. Signed-off-by: Arvind Yadav --- 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