- new_slot = (struct slot *) kmalloc(sizeof(struct slot), GFP_KERNEL);
- if (!new_slot)
- return -ENOMEM;
-
- memset(new_slot, 0, sizeof(struct slot));
- new_slot->hotplug_slot = kmalloc (sizeof (struct hotplug_slot), GFP_KERNEL);
- if (!new_slot->hotplug_slot) {
- kfree (new_slot);
- return -ENOMEM;
- }
- memset(new_slot->hotplug_slot, 0, sizeof (struct hotplug_slot));
-
- new_slot->hotplug_slot->info = kmalloc (sizeof (struct hotplug_slot_info), GFP_KERNEL);
- if (!new_slot->hotplug_slot->info) {
- kfree (new_slot->hotplug_slot);
- kfree (new_slot);
- return -ENOMEM;
- }
- memset(new_slot->hotplug_slot->info, 0, sizeof (struct hotplug_slot_info));
- new_slot->hotplug_slot->name = kmalloc (SLOT_NAME_SIZE, GFP_KERNEL);
- if (!new_slot->hotplug_slot->name) {
- kfree (new_slot->hotplug_slot->info);
- kfree (new_slot->hotplug_slot);
- kfree (new_slot);
- return -ENOMEM;
- }
-
- new_slot->magic = SLOT_MAGIC;
- new_slot->ctrl = ctrl;
- new_slot->bus = ctrl->slot_bus;
- new_slot->device = slot_device;
- new_slot->hpc_ops = ctrl->hpc_ops;
-
- new_slot->number = ctrl->first_slot;
- new_slot->hp_slot = slot_device - ctrl->slot_device_offset;
+ slot = kzalloc(sizeof(*slot), GFP_KERNEL);
+ if (!slot)
+ goto error;
+
+ slot->hotplug_slot =
+ kzalloc(sizeof(*(slot->hotplug_slot)),
+ GFP_KERNEL);
+ if (!slot->hotplug_slot)
+ goto error_slot;
+ hotplug_slot = slot->hotplug_slot;
+
+ hotplug_slot->info =
+ kzalloc(sizeof(*(hotplug_slot->info)),
+ GFP_KERNEL);
+ if (!hotplug_slot->info)
+ goto error_hpslot;
+ hotplug_slot_info = hotplug_slot->info;
+ hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
+ if (!hotplug_slot->name)
+ goto error_info;
+
+ slot->ctrl = ctrl;
+ slot->bus = ctrl->slot_bus;
+ slot->device = slot_device;
+ slot->hpc_ops = hpc_ops = ctrl->hpc_ops;
+
+ slot->number = ctrl->first_slot;
+ slot->hp_slot = slot_device - ctrl->slot_device_offset;