EDAC: Handle return value of kasprintf()
kasprintf() can fail and we must check its return value. Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com> Cc: linux-edac@vger.kernel.org [ Merged into a single patch, small formatting fixups. ] Signed-off-by: Borislav Petkov <bp@suse.de>
This commit is contained in:
parent
2bd6bf03f4
commit
75f029c3a8
|
@ -2159,8 +2159,13 @@ static int i7core_register_mci(struct i7core_dev *i7core_dev)
|
|||
mci->edac_ctl_cap = EDAC_FLAG_NONE;
|
||||
mci->edac_cap = EDAC_FLAG_NONE;
|
||||
mci->mod_name = "i7core_edac.c";
|
||||
mci->ctl_name = kasprintf(GFP_KERNEL, "i7 core #%d",
|
||||
i7core_dev->socket);
|
||||
|
||||
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,8 @@ 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;
|
||||
|
|
|
@ -3287,6 +3287,11 @@ static int sbridge_register_mci(struct sbridge_dev *sbridge_dev, enum type type)
|
|||
break;
|
||||
}
|
||||
|
||||
if (!mci->ctl_name) {
|
||||
rc = -ENOMEM;
|
||||
goto fail0;
|
||||
}
|
||||
|
||||
/* Get dimm basic config and the memory layout */
|
||||
rc = get_dimm_config(mci);
|
||||
if (rc < 0) {
|
||||
|
|
|
@ -464,8 +464,12 @@ static int skx_register_mci(struct skx_imc *imc)
|
|||
pvt = mci->pvt_info;
|
||||
pvt->imc = imc;
|
||||
|
||||
mci->ctl_name = kasprintf(GFP_KERNEL, "Skylake Socket#%d IMC#%d",
|
||||
imc->node_id, imc->lmc);
|
||||
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 +495,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;
|
||||
|
|
Loading…
Reference in a new issue