summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-06-16 09:21:01 +0530
committerLinus Torvalds <torvalds@linux-foundation.org>2026-06-16 09:21:01 +0530
commit481329ec5b31d2c48ac6b8b703c8008133884c7e (patch)
tree406bb78e41609a198710f5e3d4880a5734a00aba /lib
parent673f72944dde6614a56b37a61c6097f584c90ce6 (diff)
parent122b52f0bab007ebeb414c8280c1def17b9ed1f4 (diff)
downloadlinux-2.6-481329ec5b31d2c48ac6b8b703c8008133884c7e.tar.gz
linux-2.6-481329ec5b31d2c48ac6b8b703c8008133884c7e.zip
Merge tag 'hardening-v7.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull hardening updates from Kees Cook: - lkdtm: - Add case to provoke a crash in EFI runtime services (Ard Biesheuvel) - add PPC_RADIX_TLBIEL test and missed isync (Sayali Patil) - stddef: Document designated initializer semantics for __TRAILING_OVERLAP() (Gustavo A. R. Silva) - strarray: drop redundant allocation, add __counted_by_ptr (Thorsten Blum) * tag 'hardening-v7.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: lkdtm/powerpc: add PPC_RADIX_TLBIEL test for radix MCE validation lkdtm/powerpc: add isync after slbmte to enforce SLB update ordering lkdtm: Add case to provoke a crash in EFI runtime services lib/string_helpers: annotate struct strarray with __counted_by_ptr lib/string_helpers: drop redundant allocation in kasprintf_strarray MAINTAINERS: add kernel hardening keyword __counted_by_ptr stddef: Document designated initializer semantics for __TRAILING_OVERLAP()
Diffstat (limited to 'lib')
-rw-r--r--lib/string_helpers.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/string_helpers.c b/lib/string_helpers.c
index 169eaf583494..98d6ed0eaab7 100644
--- a/lib/string_helpers.c
+++ b/lib/string_helpers.c
@@ -752,7 +752,7 @@ EXPORT_SYMBOL_GPL(kstrdup_and_replace);
* kasprintf_strarray - allocate and fill array of sequential strings
* @gfp: flags for the slab allocator
* @prefix: prefix to be used
- * @n: amount of lines to be allocated and filled
+ * @n: number of strings to be allocated and filled
*
* Allocates and fills @n strings using pattern "%s-%zu", where prefix
* is provided by caller. The caller is responsible to free them with
@@ -765,7 +765,7 @@ char **kasprintf_strarray(gfp_t gfp, const char *prefix, size_t n)
char **names;
size_t i;
- names = kcalloc(n + 1, sizeof(char *), gfp);
+ names = kcalloc(n, sizeof(char *), gfp);
if (!names)
return NULL;
@@ -805,7 +805,7 @@ void kfree_strarray(char **array, size_t n)
EXPORT_SYMBOL_GPL(kfree_strarray);
struct strarray {
- char **array;
+ char **array __counted_by_ptr(n);
size_t n;
};
@@ -824,13 +824,13 @@ char **devm_kasprintf_strarray(struct device *dev, const char *prefix, size_t n)
if (!ptr)
return ERR_PTR(-ENOMEM);
+ ptr->n = n;
ptr->array = kasprintf_strarray(GFP_KERNEL, prefix, n);
if (!ptr->array) {
devres_free(ptr);
return ERR_PTR(-ENOMEM);
}
- ptr->n = n;
devres_add(dev, ptr);
return ptr->array;