Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752698AbbLATYi (ORCPT ); Tue, 1 Dec 2015 14:24:38 -0500 Received: from mail-yk0-f169.google.com ([209.85.160.169]:34372 "EHLO mail-yk0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750870AbbLATYg (ORCPT ); Tue, 1 Dec 2015 14:24:36 -0500 Subject: Re: [PATCH] xen-pciback: fix up cleanup path when alloc fails To: Konrad Rzeszutek Wilk References: <1448569959-7245-1-git-send-email-cardoe@cardoe.com> <20151201164717.GA5032@char.us.oracle.com> Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Bob Liu , Paul Durrant , Wei Liu , David Vrabel , Boris Ostrovsky , Jonathan Creekmore From: Doug Goldstein Message-ID: <565DF3EE.7060309@cardoe.com> Date: Tue, 1 Dec 2015 13:24:30 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20151201164717.GA5032@char.us.oracle.com> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="SWuDnwD6Rnk0WTP8CIT2U4w23S7ODO1xv" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3081 Lines: 90 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --SWuDnwD6Rnk0WTP8CIT2U4w23S7ODO1xv Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 12/1/15 10:47 AM, Konrad Rzeszutek Wilk wrote: > On Thu, Nov 26, 2015 at 02:32:39PM -0600, Doug Goldstein wrote: >> When allocating a pciback device fails, avoid the possibility of a >> use after free. >=20 > Reviewed-by: Konrad Rzeszutek Wilk >=20 > Ugh, and it looks like xen-blkfront has the same issue. I believe that case is covered because xen_blkbk_remove() is called in all the failure cases of xen_blkbk_probe() in that case. >=20 >> >> Reported-by: Jonathan Creekmore >> Signed-off-by: Doug Goldstein >> --- >> drivers/xen/xen-pciback/xenbus.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pcibac= k/xenbus.c >> index 98bc345..4843741 100644 >> --- a/drivers/xen/xen-pciback/xenbus.c >> +++ b/drivers/xen/xen-pciback/xenbus.c >> @@ -44,7 +44,6 @@ static struct xen_pcibk_device *alloc_pdev(struct xe= nbus_device *xdev) >> dev_dbg(&xdev->dev, "allocated pdev @ 0x%p\n", pdev); >> =20 >> pdev->xdev =3D xdev; >> - dev_set_drvdata(&xdev->dev, pdev); >> =20 >> mutex_init(&pdev->dev_lock); >> =20 >> @@ -58,6 +57,9 @@ static struct xen_pcibk_device *alloc_pdev(struct xe= nbus_device *xdev) >> kfree(pdev); >> pdev =3D NULL; >> } >> + >> + dev_set_drvdata(&xdev->dev, pdev); >> + >> out: >> return pdev; >> } >> --=20 >> 2.4.10 >> --=20 Doug Goldstein --SWuDnwD6Rnk0WTP8CIT2U4w23S7ODO1xv Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0 iQJ8BAEBCgBmBQJWXfPxXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRBNTM5MEQ2RTNFMTkyNzlCNzVDMzIwOTVB MkJDMDNEQzg3RUQxQkQ0AAoJEKK8A9yH7RvUTUYP/30CXdxIkl5pq8BEaZzJ9Gb2 3/rLyEjrYWv7p+YTI9rHxzqvF47QKFKD33dYGUXsFB6G6RebskBByU5FDbED0q7K IwRpmt6USlxcwQ+IYN8w/sU33lMODud9MgH31kJM6tp8+jRig/Fwm0p6j61UGgco dh3EEapSdftpbPaVQWHCp5irEU3v6CAsDkLeJuOVPKuwagYm6qrc+xLgQAAY6koD e+mqT9imqv318RkObNhADEbycOHJuPQOlXuP/p64LEYGPzQ6AGDWBZhRry9mGwjM 0qKkdCr/EKobpCIVme4ckYT8l5M73/zUVhKFsohZy2SZJGWEt1/goBO/FpVQMQSV 8hQE5tVNzxC4ay2IvsLQLR2K6/Unlmq7GDs+zwm35/vuehr9Mk48TQApi3PnE8sT xpakWTRAwGzQcWO4VyN7carwxSGz/+7dTY29IPkn8USael8Dp/3nl0cDXF2qzktX GILxI2AElqpE1reE7Vg3hSbY2CZ0QuNOfo7/FdE5yhguiK1kT7zy9gB/MI9m4zqR lixETjrSvkyjGApb8J5KiKJbcYi/KaoKjc6ZMWAd2EltGPzH/4H5DdgCxpudeXBY Sj+38cA70k4er9+qdODGSrGhR8krWLAORvjp8F5kkNyXWfDFl+wE48nSbKGq53QE 3gVtKv3pnXpQ9Ny80P/5 =SDDt -----END PGP SIGNATURE----- --SWuDnwD6Rnk0WTP8CIT2U4w23S7ODO1xv-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/