2017-09-21 07:54:15

by Arvind Yadav

[permalink] [raw]
Subject: [PATCH 0/3] EDAC: Handle return value of kasprintf

kasprintf() can fail here and we must check its return value.

Arvind Yadav (3):
[PATCH 1/3] EDAC: i7core: Handle return value of kasprintf
[PATCH 2/3] EDAC: sb_edac: Handle return value of kasprintf
[PATCH 3/3] EDAC: skx_edac: Handle return value of kasprintf

drivers/edac/i7core_edac.c | 6 ++++++
drivers/edac/sb_edac.c | 4 ++++
drivers/edac/skx_edac.c | 6 ++++++
3 files changed, 16 insertions(+)

--
1.9.1


2017-09-21 07:54:25

by Arvind Yadav

[permalink] [raw]
Subject: [PATCH 3/3] EDAC: skx_edac: Handle return value of kasprintf

kasprintf() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <[email protected]>
---
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

2017-09-21 07:54:21

by Arvind Yadav

[permalink] [raw]
Subject: [PATCH 1/3] EDAC: i7core: Handle return value of kasprintf

kasprintf() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <[email protected]>
---
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

2017-09-21 07:54:50

by Arvind Yadav

[permalink] [raw]
Subject: [PATCH 2/3] EDAC: sb_edac: Handle return value of kasprintf

kasprintf() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <[email protected]>
---
drivers/edac/sb_edac.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
index dc05916..2b9e831 100644
--- a/drivers/edac/sb_edac.c
+++ b/drivers/edac/sb_edac.c
@@ -3286,6 +3286,10 @@ static int sbridge_register_mci(struct sbridge_dev *sbridge_dev, enum type type)
pvt->sbridge_dev->source_id, pvt->sbridge_dev->dom);
break;
}
+ if (!mci->ctl_name) {
+ rc = -ENOMEM;
+ goto fail0;
+ }

/* Get dimm basic config and the memory layout */
rc = get_dimm_config(mci);
--
1.9.1

2017-09-21 10:20:14

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH 0/3] EDAC: Handle return value of kasprintf

On Thu, Sep 21, 2017 at 01:23:10PM +0530, Arvind Yadav wrote:
> kasprintf() can fail here and we must check its return value.
>
> Arvind Yadav (3):
> [PATCH 1/3] EDAC: i7core: Handle return value of kasprintf
> [PATCH 2/3] EDAC: sb_edac: Handle return value of kasprintf
> [PATCH 3/3] EDAC: skx_edac: Handle return value of kasprintf
>
> drivers/edac/i7core_edac.c | 6 ++++++
> drivers/edac/sb_edac.c | 4 ++++
> drivers/edac/skx_edac.c | 6 ++++++
> 3 files changed, 16 insertions(+)

Merged into a single patch and applied.

Thanks.

--
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.
--