mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
firmware: arm_scmi: quirk: Improve quirk range parsing
When a range contains only an end ("-X"), the number string is parsed
twice, as both "sep == first" and "sep != last" are true. Fix this by
dropping the superfluous number parsing for "sep == first".
This does have a harmless functional impact for the unbounded range:
"-" is now accepted, while it was rejected before.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://patch.msgid.link/fe257b3b7b7b5c17fd0e5727bb9746c731bd7e3c.1775205358.git.geert+renesas@glider.be
(sudeep.holla: Initialise ret to 0 as it will be uninitialise for "-" range)
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
This commit is contained in:
parent
0c6eb5d019
commit
6991e5de97
|
|
@ -219,9 +219,9 @@ static unsigned int scmi_quirk_signature(const char *vend, const char *sub_vend)
|
|||
static int scmi_quirk_range_parse(struct scmi_quirk *quirk)
|
||||
{
|
||||
const char *last, *first __free(kfree) = NULL;
|
||||
int ret = 0;
|
||||
size_t len;
|
||||
char *sep;
|
||||
int ret;
|
||||
|
||||
quirk->start_range = 0;
|
||||
quirk->end_range = 0xFFFFFFFF;
|
||||
|
|
@ -238,16 +238,15 @@ static int scmi_quirk_range_parse(struct scmi_quirk *quirk)
|
|||
if (sep)
|
||||
*sep = '\0';
|
||||
|
||||
if (sep == first) /* -X */
|
||||
ret = kstrtouint(first + 1, 0, &quirk->end_range);
|
||||
else /* X OR X- OR X-y */
|
||||
if (sep != first) /* X OR X- OR X-y */ {
|
||||
ret = kstrtouint(first, 0, &quirk->start_range);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!sep)
|
||||
quirk->end_range = quirk->start_range;
|
||||
else if (sep != last) /* x-Y */
|
||||
else if (sep != last) /* -X OR x-Y */
|
||||
ret = kstrtouint(sep + 1, 0, &quirk->end_range);
|
||||
|
||||
if (quirk->start_range > quirk->end_range)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user