* [to-be-updated] lib-introduce-simple-error-checking-wrapper-for-memparse.patch removed from -mm tree
@ 2026-01-21 0:26 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-01-21 0:26 UTC (permalink / raw)
To: mm-commits, kees, hch, cem, andy, dmantipov, akpm
The quilt patch titled
Subject: lib: introduce simple error-checking wrapper for memparse()
has been removed from the -mm tree. Its filename was
lib-introduce-simple-error-checking-wrapper-for-memparse.patch
This patch was dropped because an updated version will be issued
------------------------------------------------------
From: Dmitry Antipov <dmantipov@yandex.ru>
Subject: lib: introduce simple error-checking wrapper for memparse()
Date: Thu, 8 Jan 2026 19:52:15 +0300
Introduce 'memvalue()' which uses 'memparse()' to parse a string with
optional memory suffix into a non-negative number. If parsing has
succeeded, returns 0 and stores the result at the location specified by
the second argument. Otherwise returns -EINVAL and leaves the location
untouched.
Link: https://lkml.kernel.org/r/20260108165216.1054625-1-dmantipov@yandex.ru
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Suggested-by: Christoph Hellwig <hch@infradead.org>
Suggested-by: Kees Cook <kees@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
Cc: Andy Shevchenko <andy@kernel.org>
Cc: Carlos Maiolino <cem@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
include/linux/string.h | 1 +
lib/cmdline.c | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+)
--- a/include/linux/string.h~lib-introduce-simple-error-checking-wrapper-for-memparse
+++ a/include/linux/string.h
@@ -319,6 +319,7 @@ DEFINE_FREE(argv_free, char **, if (!IS_
extern int get_option(char **str, int *pint);
extern char *get_options(const char *str, int nints, int *ints);
extern unsigned long long memparse(const char *ptr, char **retptr);
+extern int __must_check memvalue(const char *ptr, unsigned long long *valptr);
extern bool parse_option_str(const char *str, const char *option);
extern char *next_arg(char *args, char **param, char **val);
--- a/lib/cmdline.c~lib-introduce-simple-error-checking-wrapper-for-memparse
+++ a/lib/cmdline.c
@@ -191,6 +191,32 @@ unsigned long long memparse(const char *
EXPORT_SYMBOL(memparse);
/**
+ * memvalue - Wrap memparse() with simple error detection
+ * @ptr: Where parse begins
+ * @valptr: Where to store result
+ *
+ * Unconditionally returns -EINVAL for a presumably negative value.
+ * Otherwise uses memparse() to parse a string into a number stored
+ * at @valptr and returns 0 or -EINVAL if an unrecognized character
+ * was encountered. For a non-zero return value, memory at @valptr
+ * is left untouched.
+ */
+int __must_check memvalue(const char *ptr, unsigned long long *valptr)
+{
+ unsigned long long ret;
+ char *end;
+
+ if (*ptr == '-')
+ return -EINVAL;
+ ret = memparse(ptr, &end);
+ if (*end)
+ return -EINVAL;
+ *valptr = ret;
+ return 0;
+}
+EXPORT_SYMBOL(memvalue);
+
+/**
* parse_option_str - Parse a string and check an option is set or not
* @str: String to be parsed
* @option: option name
_
Patches currently in -mm which might be from dmantipov@yandex.ru are
ocfs2-adjust-ocfs2_xa_remove_entry-to-match-ubsan-boundary-checks.patch
ocfs2-annotate-more-flexible-array-members-with-__counted_by_le.patch
xfs-adjust-handling-of-a-few-numerical-mount-options.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-01-21 0:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-21 0:26 [to-be-updated] lib-introduce-simple-error-checking-wrapper-for-memparse.patch removed from -mm tree Andrew Morton
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.