Remove the attributes group before disk to avoid use after free
Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
                BUG();
        }
 
-       /* Stop new requests to arrive */
-       del_gendisk(old->disk);
-
        if (old->disk_attributes)
                sysfs_remove_group(&disk_to_dev(old->disk)->kobj,
                                                old->disk_attributes);
 
+       /* Stop new requests to arrive */
+       del_gendisk(old->disk);
+
+
        /* Stop the thread */
        kthread_stop(old->thread);