* + lib-cmdline-fix-get_option-for-strings-starting-with-hyphen.patch added to -mm tree
@ 2020-11-12 19:32 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2020-11-12 19:32 UTC (permalink / raw)
To: andriy.shevchenko, brendanhiggins, broonie, davidgow,
matti.vaittinen, mm-commits, skhan, vitor
The patch titled
Subject: lib/cmdline: fix get_option() for strings starting with hyphen
has been added to the -mm tree. Its filename is
lib-cmdline-fix-get_option-for-strings-starting-with-hyphen.patch
This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/lib-cmdline-fix-get_option-for-strings-starting-with-hyphen.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/lib-cmdline-fix-get_option-for-strings-starting-with-hyphen.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: lib/cmdline: fix get_option() for strings starting with hyphen
When string doesn't have an integer and starts from hyphen get_option()
may return interesting results. Fix it to return 0.
The simple_strtoull() is used due to absence of simple_strtoul() in a boot
code on some architectures.
Note, the Fixes tag below is rather for anthropological curiosity.
Link: https://lkml.kernel.org/r/20201112180732.75589-4-andriy.shevchenko@linux.intel.com
Fixes: f68565831e72 ("Import 2.4.0-test2pre3")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Brendan Higgins <brendanhiggins@google.com>
Cc: David Gow <davidgow@google.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Cc: Vitor Massaru Iha <vitor@massaru.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
lib/cmdline.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
--- a/lib/cmdline.c~lib-cmdline-fix-get_option-for-strings-starting-with-hyphen
+++ a/lib/cmdline.c
@@ -45,6 +45,9 @@ static int get_range(char **str, int *pi
* 1 - int found, no subsequent comma
* 2 - int found including a subsequent comma
* 3 - hyphen found to denote a range
+ *
+ * Leading hyphen without integer is no integer case, but we consume it
+ * for the sake of simplification.
*/
int get_option(char **str, int *pint)
@@ -53,7 +56,10 @@ int get_option(char **str, int *pint)
if (!cur || !(*cur))
return 0;
- *pint = simple_strtol(cur, str, 0);
+ if (*cur == '-')
+ *pint = -simple_strtoull(++cur, str, 0);
+ else
+ *pint = simple_strtoull(cur, str, 0);
if (cur == *str)
return 0;
if (**str == ',') {
_
Patches currently in -mm which might be from andriy.shevchenko@linux.intel.com are
kernelh-split-out-mathematical-helpers.patch
bitmap-convert-bitmap_empty-bitmap_full-to-return-boolean.patch
lib-list_kunit-follow-new-file-name-convention-for-kunit-tests.patch
lib-linear_ranges_kunit-follow-new-file-name-convention-for-kunit-tests.patch
lib-bits_kunit-follow-new-file-name-convention-for-kunit-tests.patch
lib-cmdline-fix-get_option-for-strings-starting-with-hyphen.patch
lib-cmdline-allow-null-to-be-an-output-for-get_option.patch
lib-cmdline_kunit-add-a-new-test-suite-for-cmdline-api.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-11-12 19:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-12 19:32 + lib-cmdline-fix-get_option-for-strings-starting-with-hyphen.patch added to -mm tree akpm
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).