Return-Path: Received: from aserp2130.oracle.com ([141.146.126.79]:40158 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727833AbeLQQAH (ORCPT ); Mon, 17 Dec 2018 11:00:07 -0500 Subject: Re: [PATCH] xen/pciback: Check dev_data before using it To: Ross Lagerwall , xen-devel@lists.xenproject.org Cc: Juergen Gross , Stefano Stabellini , stable References: <20181214125545.28753-1-ross.lagerwall@citrix.com> From: Boris Ostrovsky Message-ID: <5466379b-5781-8fa3-3fd7-765375912938@oracle.com> Date: Mon, 17 Dec 2018 10:59:27 -0500 MIME-Version: 1.0 In-Reply-To: <20181214125545.28753-1-ross.lagerwall@citrix.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: stable-owner@vger.kernel.org List-ID: On 12/14/18 7:55 AM, Ross Lagerwall wrote: > If pcistub_init_device fails, the release function will be called with > dev_data set to NULL. Check it before using it to avoid a NULL pointer > dereference. > > Signed-off-by: Ross Lagerwall I think this should go to stable trees too (copying them) Applied to for-linus-4.21 -boris > --- > drivers/xen/xen-pciback/pci_stub.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/xen/xen-pciback/pci_stub.c b/drivers/xen/xen-pciback/pci_stub.c > index 59661db144e5..097410a7cdb7 100644 > --- a/drivers/xen/xen-pciback/pci_stub.c > +++ b/drivers/xen/xen-pciback/pci_stub.c > @@ -106,7 +106,8 @@ static void pcistub_device_release(struct kref *kref) > * is called from "unbind" which takes a device_lock mutex. > */ > __pci_reset_function_locked(dev); > - if (pci_load_and_free_saved_state(dev, &dev_data->pci_saved_state)) > + if (dev_data && > + pci_load_and_free_saved_state(dev, &dev_data->pci_saved_state)) > dev_info(&dev->dev, "Could not reload PCI state\n"); > else > pci_restore_state(dev);