From: Cezary Rojewski <cezary.rojewski@intel.com>
To: "Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>,
andy@kernel.org, broonie@kernel.org
Cc: <alsa-devel@alsa-project.org>, <tiwai@suse.com>, <perex@perex.cz>,
<amadeuszx.slawinski@linux.intel.com>,
<pierre-louis.bossart@linux.intel.com>, <hdegoede@redhat.com>,
<ranjani.sridharan@linux.intel.com>,
<linux-kernel@vger.kernel.org>, <lgirdwood@gmail.com>,
<kai.vehmanen@linux.intel.com>, <yung-chuan.liao@linux.intel.com>
Subject: Re: [PATCH 1/2] lib/string_helpers: Introduce strsplit_u32()
Date: Fri, 8 Jul 2022 13:33:37 +0200 [thread overview]
Message-ID: <f05a9b04-b635-df6f-1c94-b44371d24041@intel.com> (raw)
In-Reply-To: <aecaf6aa-12b0-05bb-8ad4-8d09ca4eff10@linux.intel.com>
On 2022-07-07 3:51 PM, Péter Ujfalusi wrote:
> On 07/07/2022 12:13, Cezary Rojewski wrote:
...
>> +int strsplit_u32(const char *str, const char *delim, u32 **tkns, size_t *num_tkns)
>> +{
>> + size_t max_count = 32;
>> + size_t count = 0;
>> + char *s, **p;
>> + u32 *buf, *tmp;
>> + int ret = 0;
>> +
>> + p = (char **)&str;
>> + *tkns = NULL;
>> + *num_tkns = 0;
>> +
>> + buf = kcalloc(max_count, sizeof(*buf), GFP_KERNEL);
>> + if (!buf)
>> + return -ENOMEM;
>> +
>> + while ((s = strsep(p, delim)) != NULL) {
>> + ret = kstrtouint(s, 0, buf + count);
>> + if (ret)
>> + goto free_buf;
>> +
>> + if (++count > max_count) {
>
> I think this should be as it was originally:
> if (++count >= max_count) {
>
> Otherwise when we reach the max_count we would not realloc to get more
> space and the data + max_count is pointing outside of the allocated area.
I believe you're right. Will change in v2.
Regards,
Czarek
next prev parent reply other threads:[~2022-07-08 11:33 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-07 9:13 Cezary Rojewski
2022-07-07 9:13 ` [PATCH 2/2] ASoC: SOF: Remove tokenize_input() Cezary Rojewski
2022-07-07 13:51 ` [PATCH 1/2] lib/string_helpers: Introduce strsplit_u32() Péter Ujfalusi
2022-07-08 11:33 ` Cezary Rojewski [this message]
2022-07-08 10:22 ` Andy Shevchenko
2022-07-08 11:29 ` Andy Shevchenko
2022-07-08 11:32 ` Cezary Rojewski
2022-07-08 11:46 ` Andy Shevchenko
2022-07-08 11:51 ` Andy Shevchenko
2022-07-08 12:13 ` Cezary Rojewski
2022-07-08 12:30 ` Andy Shevchenko
2022-07-08 12:35 ` Péter Ujfalusi
2022-07-08 15:25 ` Andy Shevchenko
2022-07-08 15:28 ` Andy Shevchenko
2022-07-08 16:32 ` Cezary Rojewski
2022-07-08 16:49 ` Andy Shevchenko
2022-07-09 8:45 ` Cezary Rojewski
2022-07-09 20:42 ` Andy Shevchenko
2022-07-12 13:51 ` Cezary Rojewski
2022-07-12 13:59 ` Andy Shevchenko
2022-07-12 14:02 ` Mark Brown
2022-07-12 14:24 ` Andy Shevchenko
2022-07-19 11:40 ` Cezary Rojewski
2022-08-09 9:55 ` Cezary Rojewski
2022-08-09 15:23 ` Andy Shevchenko
2022-08-16 9:28 ` Cezary Rojewski
2022-08-25 15:09 ` Andy Shevchenko
2022-08-25 16:44 ` Cezary Rojewski
2022-07-13 9:14 ` David Laight
2022-07-13 9:38 ` Andy Shevchenko
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=f05a9b04-b635-df6f-1c94-b44371d24041@intel.com \
--to=cezary.rojewski@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=amadeuszx.slawinski@linux.intel.com \
--cc=andy@kernel.org \
--cc=broonie@kernel.org \
--cc=hdegoede@redhat.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=tiwai@suse.com \
--cc=yung-chuan.liao@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®