}
 }
 
+static inline void mark_failed_objexts_alloc(struct slab *slab)
+{
+       slab->obj_exts = OBJEXTS_ALLOC_FAIL;
+}
+
+static inline void handle_failed_objexts_alloc(unsigned long obj_exts,
+                       struct slabobj_ext *vec, unsigned int objects)
+{
+       /*
+        * If vector previously failed to allocate then we have live
+        * objects with no tag reference. Mark all references in this
+        * vector as empty to avoid warnings later on.
+        */
+       if (obj_exts & OBJEXTS_ALLOC_FAIL) {
+               unsigned int i;
+
+               for (i = 0; i < objects; i++)
+                       set_codetag_empty(&vec[i].ref);
+       }
+}
+
 #else /* CONFIG_MEM_ALLOC_PROFILING_DEBUG */
 
 static inline void mark_objexts_empty(struct slabobj_ext *obj_exts) {}
+static inline void mark_failed_objexts_alloc(struct slab *slab) {}
+static inline void handle_failed_objexts_alloc(unsigned long obj_exts,
+                       struct slabobj_ext *vec, unsigned int objects) {}
 
 #endif /* CONFIG_MEM_ALLOC_PROFILING_DEBUG */
 
                               gfp_t gfp, bool new_slab)
 {
        unsigned int objects = objs_per_slab(s, slab);
-       unsigned long obj_exts;
-       void *vec;
+       unsigned long new_exts;
+       unsigned long old_exts;
+       struct slabobj_ext *vec;
 
        gfp &= ~OBJCGS_CLEAR_MASK;
        /* Prevent recursive extension vector allocation */
        gfp |= __GFP_NO_OBJ_EXT;
        vec = kcalloc_node(objects, sizeof(struct slabobj_ext), gfp,
                           slab_nid(slab));
-       if (!vec)
+       if (!vec) {
+               /* Mark vectors which failed to allocate */
+               if (new_slab)
+                       mark_failed_objexts_alloc(slab);
+
                return -ENOMEM;
+       }
 
-       obj_exts = (unsigned long)vec;
+       new_exts = (unsigned long)vec;
 #ifdef CONFIG_MEMCG
-       obj_exts |= MEMCG_DATA_OBJEXTS;
+       new_exts |= MEMCG_DATA_OBJEXTS;
 #endif
+       old_exts = slab->obj_exts;
+       handle_failed_objexts_alloc(old_exts, vec, objects);
        if (new_slab) {
                /*
                 * If the slab is brand new and nobody can yet access its
                 * obj_exts, no synchronization is required and obj_exts can
                 * be simply assigned.
                 */
-               slab->obj_exts = obj_exts;
-       } else if (cmpxchg(&slab->obj_exts, 0, obj_exts)) {
+               slab->obj_exts = new_exts;
+       } else if (cmpxchg(&slab->obj_exts, old_exts, new_exts) != old_exts) {
                /*
                 * If the slab is already in use, somebody can allocate and
                 * assign slabobj_exts in parallel. In this case the existing