Skip to content

Commit

Permalink
KVM: Add proper lockdep assertion in I/O bus unregister
Browse files Browse the repository at this point in the history
Convert a comment above kvm_io_bus_unregister_dev() into an actual
lockdep assertion, and opportunistically add curly braces to a multi-line
for-loop.

Signed-off-by: Sean Christopherson <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
sean-jc authored and bonzini committed Apr 20, 2021
1 parent 5d3c4c7 commit 7c896d3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4620,21 +4620,23 @@ int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
return 0;
}

/* Caller must hold slots_lock. */
int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx,
struct kvm_io_device *dev)
{
int i, j;
struct kvm_io_bus *new_bus, *bus;

lockdep_assert_held(&kvm->slots_lock);

bus = kvm_get_bus(kvm, bus_idx);
if (!bus)
return 0;

for (i = 0; i < bus->dev_count; i++)
for (i = 0; i < bus->dev_count; i++) {
if (bus->range[i].dev == dev) {
break;
}
}

if (i == bus->dev_count)
return 0;
Expand Down

0 comments on commit 7c896d3

Please sign in to comment.