From: Dan Carpenter <dan.carpenter@oracle.com>
To: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@st.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] stm: class: dummy_stm: fix an error code in dummy_stm_init()
Date: Fri, 19 Mar 2021 17:46:37 +0300 [thread overview]
Message-ID: <YFS5TWHDqL7nIBEv@mwanda> (raw)
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
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@st.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] stm: class: dummy_stm: fix an error code in dummy_stm_init()
Date: Fri, 19 Mar 2021 17:46:37 +0300 [thread overview]
Message-ID: <YFS5TWHDqL7nIBEv@mwanda> (raw)
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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2021-03-19 14:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-19 14:46 Dan Carpenter [this message]
2021-03-19 14:46 ` [PATCH] stm: class: dummy_stm: fix an error code in dummy_stm_init() Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YFS5TWHDqL7nIBEv@mwanda \
--to=dan.carpenter@oracle.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=alexandre.torgue@st.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.