diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/slub.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/mm/slub.c b/mm/slub.c index dc59b9e8c66f..8f80d9bc507f 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5874,7 +5874,7 @@ static inline struct kset *cache_kset(struct kmem_cache *s) return slab_kset; } -#define ID_STR_LENGTH 64 +#define ID_STR_LENGTH 32 /* Create a unique string id for a slab cache: * @@ -5907,9 +5907,12 @@ static char *create_unique_id(struct kmem_cache *s) *p++ = 'A'; if (p != name + 1) *p++ = '-'; - p += sprintf(p, "%07u", s->size); + p += snprintf(p, ID_STR_LENGTH - (p - name), "%07u", s->size); - BUG_ON(p > name + ID_STR_LENGTH - 1); + if (WARN_ON(p > name + ID_STR_LENGTH - 1)) { + kfree(name); + return ERR_PTR(-EINVAL); + } return name; } |