Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp730960ybc; Sat, 16 Nov 2019 07:43:08 -0800 (PST) X-Google-Smtp-Source: APXvYqzWNF7NcCAfF9fMXSPTy14m4YS1scrHJysYlFEnLgVqf0k6DVTwQotUtvurkdotrvuRF6QD X-Received: by 2002:a17:906:7750:: with SMTP id o16mr10821896ejn.224.1573918987951; Sat, 16 Nov 2019 07:43:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573918987; cv=none; d=google.com; s=arc-20160816; b=XvT9ndkeraBXxVrFz2Lu/0aTyYpSfbDYf6/1iHnZj+DZLdxVEk7tEyKhCQzfjeX+r0 qGgElUhGLEBez0qDDcVnrmjgWUftLUpeb2L+GAmDjn3xkc+k77A6QH8xd97/c3JxsxKD Rs5gA1BeVqM3g6ziF5TEbcdVZFZwQjaqV/tJbhRI3qSlCC4cBK/MMaN7u5iQmYVtUdq3 KOnXw3aX1cRPM/7te4X0S3sM6boZLbDc2hnChX5sGOBF6Q7JFvIO8F2ghBnO2zh5yLWj W6Ud9G86VUvfhbvbjCtjKtU25c5uRdB63oIfM8hFHic6bOQ+Mg7IGaxInAdHsoIsD3n6 XuRw== 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=6h2kB4z+SIfkX4NtYUnROaVfs4yphZ+tBMNuEE40auk=; b=wIQ/qnGzZt87oxUeyl8mHIH/0ordqi+3BWxZ+5Djkmk+73RH+kTjTqLur+Fg72r8dL mX109OQiqZ97Divwet0BKM6b9VeUaFNdhVMqiGD9KiZquH/JnFA9lRbpqIoG7Zx9dYlf uOF1BSJkG+so3gj166fv9AGsuAP2epSqDSgRLTJk712CLoGphe0bxPXU7xoErGPTZAN6 hPfMFPvyXXpsL4goLSMKKG4kAKmjNnnJb0Gr1S9A2tv5rRC/Rw3rEVBj8AiSD/qYpfJi hScRY2aIjTDT3NIdx/4FGQV0Hp+XrcHt8pW8YjUjI32ax4rF+Hb/Vt8eGNNrYmnuw31A 83Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vT80DI2I; 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 c5si8989700edc.246.2019.11.16.07.42.43; Sat, 16 Nov 2019 07:43:07 -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=vT80DI2I; 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 S1727892AbfKPPlb (ORCPT + 99 others); Sat, 16 Nov 2019 10:41:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:44478 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727864AbfKPPlZ (ORCPT ); Sat, 16 Nov 2019 10:41:25 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (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 CCB6B20748; Sat, 16 Nov 2019 15:41:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573918885; bh=OS/5XB3eSaY5RKOQ6B/n+XCJ2R6bB2P+uS/f2k4ORzg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vT80DI2Ifn5+zhwS3dR3RXRmzyu6iyHbpxkaCoDnW5Hrhzb33g2kA1lL1c/BROmAb mRNaeEZT9Aok1HpEhO6H8skE1e3WsDj/Dpb/wMr0x0h5HFWuU7Y6LZibcRoZlIDCTp Oy1sAuwjbBwLVibV2LDGc5az1ptKy2YULYfI93W4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sam Bobroff , Michael Ellerman , Sasha Levin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 4.19 013/237] powerpc/eeh: Fix null deref for devices removed during EEH Date: Sat, 16 Nov 2019 10:37:28 -0500 Message-Id: <20191116154113.7417-13-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-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: Sam Bobroff [ Upstream commit bcbe3730531239abd45ab6c6af4a18078b37dd47 ] If a device is removed during EEH processing (either by a driver's handler or as part of recovery), it can lead to a null dereference in eeh_pe_report_edev(). To handle this, skip devices that have been removed. Signed-off-by: Sam Bobroff Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/kernel/eeh_driver.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c index 110eba400de7c..af1f3d5f9a0f7 100644 --- a/arch/powerpc/kernel/eeh_driver.c +++ b/arch/powerpc/kernel/eeh_driver.c @@ -281,6 +281,10 @@ static void eeh_pe_report_edev(struct eeh_dev *edev, eeh_report_fn fn, struct pci_driver *driver; enum pci_ers_result new_result; + if (!edev->pdev) { + eeh_edev_info(edev, "no device"); + return; + } device_lock(&edev->pdev->dev); if (eeh_edev_actionable(edev)) { driver = eeh_pcid_get(edev->pdev); -- 2.20.1