Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753481AbbKZUdD (ORCPT ); Thu, 26 Nov 2015 15:33:03 -0500 Received: from mail-yk0-f174.google.com ([209.85.160.174]:33905 "EHLO mail-yk0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752110AbbKZUdA (ORCPT ); Thu, 26 Nov 2015 15:33:00 -0500 From: Doug Goldstein To: xen-devel@lists.xenproject.org Cc: linux-kernel@vger.kernel.org, Bob Liu , Paul Durrant , Wei Liu , David Vrabel , Boris Ostrovsky , Konrad Rzeszutek Wilk , Jonathan Creekmore , Doug Goldstein Subject: [PATCH] xen-pciback: fix up cleanup path when alloc fails Date: Thu, 26 Nov 2015 14:32:39 -0600 Message-Id: <1448569959-7245-1-git-send-email-cardoe@cardoe.com> X-Mailer: git-send-email 2.4.10 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1169 Lines: 39 When allocating a pciback device fails, avoid the possibility of a use after free. 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-pciback/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 xenbus_device *xdev) dev_dbg(&xdev->dev, "allocated pdev @ 0x%p\n", pdev); pdev->xdev = xdev; - dev_set_drvdata(&xdev->dev, pdev); mutex_init(&pdev->dev_lock); @@ -58,6 +57,9 @@ static struct xen_pcibk_device *alloc_pdev(struct xenbus_device *xdev) kfree(pdev); pdev = NULL; } + + dev_set_drvdata(&xdev->dev, pdev); + out: return pdev; } -- 2.4.10 -- 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/