History

KVM: arm64: vgic-its: Simplify MAPI error handling

If we care to move all the checks that do not involve any memory allocation, we can simplify the MAPI error handling. Let's do that, it cannot hurt.

Marc Zyngier committed 10 years ago

Commit 3a88bde1 parent a3e7aa21 file · +12 −18Browse files

Unified · Split

virt/kvm/arm/vgic/vgic-its.c+12−18
@@ -697,36 +697,34 @@ static int vgic_its_cmd_handle_mapi(struct kvm *kvm, struct vgic_its *its, · 696 unmodified lines
697697 struct its_device *device;
698698 struct its_collection *collection, *new_coll = NULL;
699699 int lpi_nr;
700− int ret;
701700
702701 device = find_its_device(its, device_id);
703702 if (!device)
704703 return E_ITS_MAPTI_UNMAPPED_DEVICE;
705704
706− collection = find_collection(its, coll_id);
707− if (!collection) {
708− ret = vgic_its_alloc_collection(its, &collection, coll_id);
709− if (ret)
710− return ret;
711− new_coll = collection;
712− }
713−
714705 if (its_cmd_get_command(its_cmd) == GITS_CMD_MAPTI)
715706 lpi_nr = its_cmd_get_physical_id(its_cmd);
716707 else
717708 lpi_nr = event_id;
718709 if (lpi_nr < GIC_LPI_OFFSET ||
719− lpi_nr >= max_lpis_propbaser(kvm->arch.vgic.propbaser)) {
720− ret = E_ITS_MAPTI_PHYSICALID_OOR;
721− goto err;
710+ lpi_nr >= max_lpis_propbaser(kvm->arch.vgic.propbaser))
711+ return E_ITS_MAPTI_PHYSICALID_OOR;
712+
713+ collection = find_collection(its, coll_id);
714+ if (!collection) {
715+ int ret = vgic_its_alloc_collection(its, &collection, coll_id);
716+ if (ret)
717+ return ret;
718+ new_coll = collection;
722719 }
723720
724721 itte = find_itte(its, device_id, event_id);
725722 if (!itte) {
726723 itte = kzalloc(sizeof(struct its_itte), GFP_KERNEL);
727724 if (!itte) {
728− ret = -ENOMEM;
729− goto err;
725+ if (new_coll)
726+ vgic_its_free_collection(its, coll_id);
727+ return -ENOMEM;
730728 }
731729
732730 itte->event_id = event_id;
@@ -746,10 +744,6 @@ static int vgic_its_cmd_handle_mapi(struct kvm *kvm, struct vgic_its *its, · 13 unmodified lines
746744 update_lpi_config(kvm, itte->irq, NULL);
747745
748746 return 0;
749−err:
750− if (new_coll)
751− vgic_its_free_collection(its, coll_id);
752− return ret;
753747 }
754748
755749 /* Requires the its_lock to be held. */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t