memcg, kmem: fix reference count handling on the error path