amd_iommu: Fix amdvi_realize() error API violation
commit475fc97d091c2cbcce0cd48c9fd70e966e5d1159
authorMarkus Armbruster <armbru@redhat.com>
Tue, 30 Jun 2020 09:03:46 +0000 (30 11:03 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Thu, 2 Jul 2020 09:54:47 +0000 (2 11:54 +0200)
tree58ff02676855e94192e05c6c5b7fc59441793d99
parent18d588fe1e178b43203532a2debdffd4f36535c5
amd_iommu: Fix amdvi_realize() error API violation

The Error ** argument must be NULL, &error_abort, &error_fatal, or a
pointer to a variable containing NULL.  Passing an argument of the
latter kind twice without clearing it in between is wrong: if the
first call sets an error, it no longer points to NULL for the second
call.

amdvi_realize() is wrong that way: it passes @errp to qdev_realize(),
object_property_get_int(), and msi_init() without checking it.  I
can't tell offhand whether qdev_realize() can fail here.  Fix by
checking it for failure.  object_property_get_int() can't.  Fix by
passing &error_abort instead.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20200630090351.1247703-22-armbru@redhat.com>
hw/i386/amd_iommu.c