Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4562104pja; Thu, 21 Nov 2019 21:55:03 -0800 (PST) X-Google-Smtp-Source: APXvYqzaJNiPBjCfqJK0JL9V4wsbfhbiCIp0oBLiRd1SBa8xWF73M96XZX69hMSa5kyqGwQ6qvi+ X-Received: by 2002:a17:906:6dc2:: with SMTP id j2mr19528058ejt.140.1574402103736; Thu, 21 Nov 2019 21:55:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574402103; cv=none; d=google.com; s=arc-20160816; b=tn+GMOZ2XaCyfS5uhhWK1+udN5siQ8iZ0IxguXLpYPXTfyWYKTtUBIPUqwBCjcvXI/ xFDfbUYwes2zvl6MQBl2YkAcIxGyx7qNO49j2vdRG+TlX3heB1IayTAOQNxtYBVspwXt sBWpDBSHORdexkA51T+tGfmFGg+vrreJgtgBh/QHE7405Mh9Qu8UYjGrHHiGBq0SCw+6 2RQZTnVCPDILhRjUUUhi69Ut2LbxYqzpd1CP8Os39MpkyFhhBsuVZT8BZI1TWg6e0BB+ Lt3oi6Z9izQb9c6J5ws/eXNLkwKBS3Z7X48janJLJ68s2VjeW8AYelZFsJIdNUOJjGP7 bQQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aXd3CA6sdLt/19e/T2YCYt/Ksdzc/RoGTZ7CxlHmiSs=; b=Wm6kikGAYrrs9SmUJQ3yRN3GRmfhykN8OJbmXuVpRn0vRRhvo2UylozfMp8ShTEx2V tNrBeGZ3HUrDLclOyJDx4kn8/qO0OJNf1vtXsYociyUIgXzHJ5lDZyHxsSHM3Q67+Mr/ 9H8x0hW4PmoYKpbf3WApjOWiWdO9Cr3CIukhNRVyEWdsALy+Ov/2n69xFtqvEjc8mAqm xGPy0Nszo47qm+S7mXPKRE1UuuuwKyFjbZkYGrQnn/CXs9cFs9P1SX3WBQD+YjQLTwzS B0WjrTw18D3N4KCskDJ2kRUGJgxpvp4V+qslc50UKIy5nD49/DneW6XdKeiObDJLh/D/ 2+Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TgP1EBMT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p29si4728956eda.104.2019.11.21.21.54.38; Thu, 21 Nov 2019 21:55:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TgP1EBMT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727862AbfKVFuq (ORCPT + 99 others); Fri, 22 Nov 2019 00:50:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:55392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727771AbfKVFul (ORCPT ); Fri, 22 Nov 2019 00:50:41 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 29A482075B; Fri, 22 Nov 2019 05:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401840; bh=UxEp8ox6OzQg67AWkKUhgIDhv14VbLfTIqTETNkCDyU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TgP1EBMTGu1yatgo8/yMCDnGPhgEQlfIXhyJySIPMuu8OcFxdYoh+83V7LX324D02 WfwGSU65Wm2CluQHx0SUhW+7xDR2OX45WT7SmQsJpGV+ClmFM/ILboEFvtZs3h23pZ SQUVGufdpjiZ29gwjrwpzo3O7D3cNwmk/JRJ0tds= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ross Lagerwall , Boris Ostrovsky , Sasha Levin , xen-devel@lists.xenproject.org Subject: [PATCH AUTOSEL 4.19 081/219] xen/pciback: Check dev_data before using it Date: Fri, 22 Nov 2019 00:46:53 -0500 Message-Id: <20191122054911.1750-74-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122054911.1750-1-sashal@kernel.org> References: <20191122054911.1750-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ross Lagerwall [ Upstream commit 1669907e3d1abfa3f7586e2d55dbbc117b5adba2 ] 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 Reviewed-by: Boris Ostrovsky Signed-off-by: Boris Ostrovsky Signed-off-by: Sasha Levin --- 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 59661db144e51..097410a7cdb74 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); -- 2.20.1