Commit 4dbac1ae authored by Markus Armbruster's avatar Markus Armbruster
Browse files

net/virtio: Drop useless n->primary_dev not null checks



virtio_net_handle_migration_primary() returns early when it can't
ensure n->primary_dev is non-null.  Checking it again right after that
early return is redundant.  Drop.

If n->primary_dev is null on entering failover_replug_primary(), @pdev
will become null, and pdev->partially_hotplugged will crash.  Checking
n->primary_dev later is useless.  It can't actually be null, because
its caller virtio_net_handle_migration_primary() ensures it isn't.
Drop the useless check.

Cc: Jens Freimann <jfreimann@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
Message-Id: <20191130194240.10517-2-armbru@redhat.com>
Reviewed-by: default avatarJens Freimann <jfreimann@redhat.com>
parent fb224688
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -2810,11 +2810,6 @@ static bool failover_replug_primary(VirtIONet *n, Error **errp)
            goto out;
        }
    }
    if (!n->primary_dev) {
            error_setg(errp, "virtio_net: couldn't find primary device");
            goto out;
    }

    n->primary_bus = n->primary_dev->parent_bus;
    if (!n->primary_bus) {
        error_setg(errp, "virtio_net: couldn't find primary bus");
@@ -2849,8 +2844,7 @@ static void virtio_net_handle_migration_primary(VirtIONet *n,
        }
    }

    if (migration_in_setup(s) && !should_be_hidden &&
        n->primary_dev) {
    if (migration_in_setup(s) && !should_be_hidden) {
        if (failover_unplug_primary(n)) {
            vmstate_unregister(n->primary_dev, qdev_get_vmsd(n->primary_dev),
                    n->primary_dev);