static inline int alloc_consistency_checks(struct kmem_cache *s,
struct slab *slab, void *object)
{
- if (!validate_slab_ptr(slab)) {
- slab_err(s, slab, "Not a valid slab page");
- return 0;
- }
-
if (!check_slab(s, slab))
return 0;
struct slab *slab, void *object, int orig_size)
{
if (s->flags & SLAB_CONSISTENCY_CHECKS) {
+ if (!validate_slab_ptr(slab)) {
+ slab_err(s, slab, "Not a valid slab page");
+ return false;
+ }
+
if (!alloc_consistency_checks(s, slab, object))
goto bad;
}
return true;
bad:
- if (validate_slab_ptr(slab)) {
- /*
- * If this is a slab page then lets do the best we can
- * to avoid issues in the future. Marking all objects
- * as used avoids touching the remaining objects.
- */
- slab_fix(s, "Marking all objects used");
- slab->inuse = slab->objects;
- slab->freelist = NULL;
- slab->frozen = 1; /* mark consistency-failed slab as frozen */
- }
+ /*
+ * Let's do the best we can to avoid issues in the future. Marking all
+ * objects as used avoids touching the remaining objects.
+ */
+ slab_fix(s, "Marking all objects used");
+ slab->inuse = slab->objects;
+ slab->freelist = NULL;
+ slab->frozen = 1; /* mark consistency-failed slab as frozen */
+
return false;
}