* [PATCH] stm: class: dummy_stm: fix an error code in dummy_stm_init()
@ 2021-03-19 14:46 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2021-03-19 14:46 UTC (permalink / raw)
To: Alexander Shishkin
Cc: Maxime Coquelin, Alexandre Torgue, Greg Kroah-Hartman,
linux-stm32, linux-arm-kernel, linux-kernel, kernel-janitors
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@oracle.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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-03-19 14:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19 14:46 [PATCH] stm: class: dummy_stm: fix an error code in dummy_stm_init() Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).