Skip to content

Commit 0bdcef5

Browse files
committed
Merge branch 'slab/for-6.1/trivial' into slab/for-next
Additional cleanup by Chao Yu removing a BUG_ON() in create_unique_id().
2 parents 5959725 + d65360f commit 0bdcef5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

mm/slub.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5751,7 +5751,7 @@ static inline struct kset *cache_kset(struct kmem_cache *s)
57515751
return slab_kset;
57525752
}
57535753

5754-
#define ID_STR_LENGTH 64
5754+
#define ID_STR_LENGTH 32
57555755

57565756
/* Create a unique string id for a slab cache:
57575757
*
@@ -5785,9 +5785,12 @@ static char *create_unique_id(struct kmem_cache *s)
57855785
*p++ = 'A';
57865786
if (p != name + 1)
57875787
*p++ = '-';
5788-
p += sprintf(p, "%07u", s->size);
5788+
p += snprintf(p, ID_STR_LENGTH - (p - name), "%07u", s->size);
57895789

5790-
BUG_ON(p > name + ID_STR_LENGTH - 1);
5790+
if (WARN_ON(p > name + ID_STR_LENGTH - 1)) {
5791+
kfree(name);
5792+
return ERR_PTR(-EINVAL);
5793+
}
57915794
return name;
57925795
}
57935796

0 commit comments

Comments
 (0)