[<prev] [next>] [day] [month] [year] [list]
Message-ID: <YFS5TWHDqL7nIBEv@mwanda>
Date: Fri, 19 Mar 2021 17:46:37 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Maxime Coquelin <mcoquelin.stm32@...il.com>,
Alexandre Torgue <alexandre.torgue@...com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org
Subject: [PATCH] stm: class: dummy_stm: fix an error code in dummy_stm_init()
If the kasprintf() allocation fails after the first iteration through
the loop then it returns success instead of -ENOMEM as intended.
Fixes: bcfdf8afdebe ("stm class: dummy_stm: Create multiple devices")
Signed-off-by: Dan Carpenter <dan.carpenter@...cle.com>
---
drivers/hwtracing/stm/dummy_stm.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/hwtracing/stm/dummy_stm.c b/drivers/hwtracing/stm/dummy_stm.c
index 38528ffdc0b3..36d32e7afb35 100644
--- a/drivers/hwtracing/stm/dummy_stm.c
+++ b/drivers/hwtracing/stm/dummy_stm.c
@@ -68,7 +68,7 @@ static int dummy_stm_link(struct stm_data *data, unsigned int master,
static int dummy_stm_init(void)
{
- int i, ret = -ENOMEM;
+ int i, ret;
if (nr_dummies < 0 || nr_dummies > DUMMY_STM_MAX)
return -EINVAL;
@@ -80,8 +80,10 @@ static int dummy_stm_init(void)
for (i = 0; i < nr_dummies; i++) {
dummy_stm[i].name = kasprintf(GFP_KERNEL, "dummy_stm.%d", i);
- if (!dummy_stm[i].name)
+ if (!dummy_stm[i].name) {
+ ret = -ENOMEM;
goto fail_unregister;
+ }
dummy_stm[i].sw_start = master_min;
dummy_stm[i].sw_end = master_max;
--
2.30.1
Powered by blists - more mailing lists