From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42F40C432C0 for ; Fri, 22 Nov 2019 06:02:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D10D2068F for ; Fri, 22 Nov 2019 06:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574402521; bh=5jl7WjR50OO6i+g7GO919wc/XN7O/dXxQlD9dBJXDhM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=yKQhQJ6tSjLbHE8Bo9vj206BN11OdQ0c/Y8LPinJJTI/oZ0MhhAabihKv7T9VXUQi RPNSdvoA3e7Cf2VcecfccYRtsEdYUmbJPSD7iq4ywGcNQeJZ3iKBq/zmZUORYE0wWQ GDiTJ0JiWgxykIMwXiYvS7c5Y44uV5fpOOL7zQRs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729475AbfKVGCA (ORCPT ); Fri, 22 Nov 2019 01:02:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:40318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729398AbfKVGB4 (ORCPT ); Fri, 22 Nov 2019 01:01:56 -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 9E6422068E; Fri, 22 Nov 2019 06:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574402516; bh=5jl7WjR50OO6i+g7GO919wc/XN7O/dXxQlD9dBJXDhM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mf5fkherQSVHuVYWN7+U7cJ3uNlkO4TUEFHlvu8szElaUPmaefHQXhxhXHVm8WehS dG+YxDqfs0kWFjWrynDGn6mHh77G1TIgQBS38UvbU4JCrze5hzB1pbOaPlh1v/2uo+ iZNgnEObIEh1UUzMSq7RgCgahG2D6AqW+2PLZ4xs= 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.9 25/91] xen/pciback: Check dev_data before using it Date: Fri, 22 Nov 2019 01:00:23 -0500 Message-Id: <20191122060129.4239-24-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122060129.4239-1-sashal@kernel.org> References: <20191122060129.4239-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 6331a95691a44..ee5ce9286d613 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