Received: from eggs.gnu.org ([2001:4830:134:3::10]:55579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bvots-0005zD-4N for qemu-devel@nongnu.org; Sun, 16 Oct 2016 13:07:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bvoto-0001gV-St for qemu-devel@nongnu.org; Sun, 16 Oct 2016 13:07:04 -0400 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]:33287) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bvoto-0001fw-K3 for qemu-devel@nongnu.org; Sun, 16 Oct 2016 13:07:00 -0400 Received: by mail-lf0-x242.google.com with SMTP id l131so19402614lfl.0 for ; Sun, 16 Oct 2016 10:07:00 -0700 (PDT) Date: Sun, 16 Oct 2016 18:06:56 +0100 From: Stefan Hajnoczi Message-ID: <20161016170656.GL2128@stefanha-x1.localdomain> References: <08db498b4f8971c9e22f350dbd8ddbde.webmail@localhost> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="PpocKf6TCvdC9BKE" Content-Disposition: inline In-Reply-To: <08db498b4f8971c9e22f350dbd8ddbde.webmail@localhost> Subject: Re: [Qemu-devel] [PATCH 4/4] Added error checking for msix_init. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Shreya Shrivastava Cc: qemu-devel@nongnu.org --PpocKf6TCvdC9BKE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Oct 16, 2016 at 12:53:16AM -0000, Shreya Shrivastava wrote: > Add checks for negative return value to uses of msix_init. > Signed-off-by: Shreya Shrivastava >=20 > --- > hw/usb/hcd-xhci.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) >=20 > diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c > index 4acf0c6..cb854aa 100644 > --- a/hw/usb/hcd-xhci.c > +++ b/hw/usb/hcd-xhci.c > @@ -3705,10 +3705,11 @@ static void usb_xhci_realize(struct PCIDevice > *dev, Error **errp) >=20 > if (xhci->msix !=3D ON_OFF_AUTO_OFF) { > /* TODO check for errors */ > - msix_init(dev, xhci->numintrs, > + ret =3D msix_init(dev, xhci->numintrs, > &xhci->mem, 0, OFF_MSIX_TABLE, > &xhci->mem, 0, OFF_MSIX_PBA, > 0x90); > + assert(ret >=3D 0); > } > } Please handle the error instead of adding an assert: 1. Use error_setg_errno(errp, -ret, "MSI-X initialization failed") so the caller knows an error occurred. 2. Look at the resources initialized by this function and pick corresponding cleanup calls from usb_xhci_exit() so they are freed. For example xhci->mfwrap_timer was created so timer_free() needs to be called. (This is easier if you can move the msix_init() call further up before resources are initialized just like the msi_init() call. But you need to check if msix_init() relies on anything before moving the call up.) --PpocKf6TCvdC9BKE Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJYA7OwAAoJEJykq7OBq3PIB4QIAL7FRepQFI+8Vhnp8OMBc7VY 1/VqiT7opN5kVaVxuf1YKeAjxFqxicBPghkeGWPmuT53gXPMUoA3N2pqtbWmZigs 2fC/ZrX0n+Q1KAqgaUoI4vZa3Upk4NVz8cOEp0YNr+TXfDiGWkTjHuS+uqTH53l3 x4fDkfmfQqxEUwJn2ctWEeEDVrmKrhVoAWqP2NaIXV0GVeTg6ZQbJY5pnpm1DWht 0hsYUfUhHQ5/5zscoazm2zRF2/FdrmdBRfhaXfeyHwSAMR7aVSbltmsSKVbKizgr fC90tcQAkxAJjCC7v/ezVwe6HHE4r5qH2NRoWrgb/L8jBBO8LdwpzFpEcsbyxm8= =C2OT -----END PGP SIGNATURE----- --PpocKf6TCvdC9BKE--