diff options
| author | Jiri Kosina <jkosina@suse.cz> | 2019-11-29 20:34:28 +0100 |
|---|---|---|
| committer | Jiri Kosina <jkosina@suse.cz> | 2019-11-29 20:34:28 +0100 |
| commit | b746a1a2860f4a918f32d10dc569115d282aaf2f (patch) | |
| tree | 4b30e6ff28e2783c73a1b763e819f5b41414563c /include/linux/string.h | |
| parent | 8725aa4fa7ded30211ebd28bb1c9bae806eb3841 (diff) | |
| parent | b03e5774d51fe003e1020060c403a1d085b128eb (diff) | |
| download | cachepc-linux-b746a1a2860f4a918f32d10dc569115d282aaf2f.tar.gz cachepc-linux-b746a1a2860f4a918f32d10dc569115d282aaf2f.zip | |
Merge branch 'for-5.5/core' into for-linus
- hid_have_special_driver[] cleanup for LED devices (Heiner Kallweit)
- HID parser improvements (Blaž Hrastnik, Candle Sun)
Diffstat (limited to 'include/linux/string.h')
| -rw-r--r-- | include/linux/string.h | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/include/linux/string.h b/include/linux/string.h index 4deb11f7976b..b6ccdc2c7f02 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -227,7 +227,26 @@ static inline bool strstarts(const char *str, const char *prefix) } size_t memweight(const void *ptr, size_t bytes); -void memzero_explicit(void *s, size_t count); + +/** + * memzero_explicit - Fill a region of memory (e.g. sensitive + * keying data) with 0s. + * @s: Pointer to the start of the area. + * @count: The size of the area. + * + * Note: usually using memset() is just fine (!), but in cases + * where clearing out _local_ data at the end of a scope is + * necessary, memzero_explicit() should be used instead in + * order to prevent the compiler from optimising away zeroing. + * + * memzero_explicit() doesn't need an arch-specific version as + * it just invokes the one of memset() implicitly. + */ +static inline void memzero_explicit(void *s, size_t count) +{ + memset(s, 0, count); + barrier_data(s); +} /** * kbasename - return the last part of a pathname. @@ -474,8 +493,9 @@ static inline void memcpy_and_pad(void *dest, size_t dest_len, * But this can lead to bugs due to typos, or if prefix is a pointer * and not a constant. Instead use str_has_prefix(). * - * Returns: 0 if @str does not start with @prefix - strlen(@prefix) if @str does start with @prefix + * Returns: + * * strlen(@prefix) if @str starts with @prefix + * * 0 if @str does not start with @prefix */ static __always_inline size_t str_has_prefix(const char *str, const char *prefix) { |
