Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1594460imd; Sun, 4 Nov 2018 06:01:55 -0800 (PST) X-Google-Smtp-Source: AJdET5dBRGvsrPbO6wFmoNF7u3x7JDH/uhDKiy55oSAYTDdRpFxET9QZ32A8fLuINOBRTnNP4rtv X-Received: by 2002:a17:902:3381:: with SMTP id b1-v6mr18518027plc.323.1541340115705; Sun, 04 Nov 2018 06:01:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541340115; cv=none; d=google.com; s=arc-20160816; b=SyQS6ZTiVzsz4Efot6K7Jv4OhrtpTsUW15OYqVroS7HPAQC+EOsxbqGa+zklYtY3Ln Z+FFH/xr2ui8eEKbPcANgSE15QmZMqkW5dQh0F+r5jOSJsE/5njxycI0AZ0KoG0D2fkW AChBjP15ObHi0tJNzWbci6xvU1w2UBzNmaRUzWxTDhtgN3YYDGmdZZoqDlG7/oiR4pS7 F9/J3fuR22xWy+llSQEJiK9XX38cI8z1+fWe5dULTmyslJsh/KdbviWgi/ns8ElQMnS9 sOHic1UujBBfcqRX1mw92ykknbwFJbV0tL5ogwPdOcm5fye3lm4GyNZ5L6dILQgcPZSK j+Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=zmW6AiLJ0DTmz8Na2zb2s5RTQ93Em/07aF3MfrPsLwE=; b=qZ/MJR6y6tUpVE9j+v6HLJnCsUDzvHkkoltQchrFNwci+S5RVFe73ubNcV69nTqlkl s7r/20rzJtwAl+3423yXf1DrgV3g9wnIjY2B+9p0TOXWz5lN5NVjFTc/b1ttRVCZfFaG plveIRTILAYH6+wdkt8e0iYeSi4JtBI1g7jmA8fRrC+UMsKfdILvUk+XF93pltQFKxxA c4dSvpEJ7G0cn4vkezTcWtg5e5aWeWiwRC/LuQyuE3UlejLSu3CONQVJftc6RV3H/w5y xNDuy7RaYTQ2ltSKdN5RBpDp0HHtSG8Ir+Jt97h3vABZUzEticU5cfZfPYR3lxxmjFQr obkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vUp1bST3; 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 be11-v6si39865092plb.193.2018.11.04.06.01.41; Sun, 04 Nov 2018 06:01:55 -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=vUp1bST3; 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 S1731788AbeKDXPx (ORCPT + 99 others); Sun, 4 Nov 2018 18:15:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:47548 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731201AbeKDXIi (ORCPT ); Sun, 4 Nov 2018 18:08:38 -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 661C72086C; Sun, 4 Nov 2018 13:53:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541339615; bh=AFIg6yxLQbQgSaaVf87pcDanS5zbx0vvaPySuBvwugk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vUp1bST30Ow+RJ+gZJvIwPNtUztHJQN/6lwqXVFKmF21Oocb3ogve3mZALAxpF8Ov O+AIVbIfae4CMczMg+49oGEI+uJx32vryihO+RCKr66TbWj1ilH0RuBsOGPHqlFj7i hskMMFcHH1+Iu66klbDQ2SlEsgDzM1muSaVQegr8= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sam Bobroff , Michael Ellerman , Sasha Levin Subject: [PATCH AUTOSEL 4.14 08/30] powerpc/eeh: Fix possible null deref in eeh_dump_dev_log() Date: Sun, 4 Nov 2018 08:53:03 -0500 Message-Id: <20181104135325.88524-8-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181104135325.88524-1-sashal@kernel.org> References: <20181104135325.88524-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sam Bobroff [ Upstream commit f9bc28aedfb5bbd572d2d365f3095c1becd7209b ] If an error occurs during an unplug operation, it's possible for eeh_dump_dev_log() to be called when edev->pdn is null, which currently leads to dereferencing a null pointer. Handle this by skipping the error log for those devices. Signed-off-by: Sam Bobroff Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/kernel/eeh.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c index 116000b45531..45322b37669a 100644 --- a/arch/powerpc/kernel/eeh.c +++ b/arch/powerpc/kernel/eeh.c @@ -169,6 +169,11 @@ static size_t eeh_dump_dev_log(struct eeh_dev *edev, char *buf, size_t len) int n = 0, l = 0; char buffer[128]; + if (!pdn) { + pr_warn("EEH: Note: No error log for absent device.\n"); + return 0; + } + n += scnprintf(buf+n, len-n, "%04x:%02x:%02x.%01x\n", pdn->phb->global_number, pdn->busno, PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn)); -- 2.17.1