From patchwork Thu Nov 2 11:01:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rameshwar Prasad Sahu X-Patchwork-Id: 10038411 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 59068603D7 for ; Thu, 2 Nov 2017 11:01:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F60228EFF for ; Thu, 2 Nov 2017 11:01:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43AA328F07; Thu, 2 Nov 2017 11:01:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AEDA628F06 for ; Thu, 2 Nov 2017 11:01:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755667AbdKBLBu (ORCPT ); Thu, 2 Nov 2017 07:01:50 -0400 Received: from [198.137.200.161] ([198.137.200.161]:39259 "EHLO denmail01.amcc.com" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1755337AbdKBLBt (ORCPT ); Thu, 2 Nov 2017 07:01:49 -0400 Received: from apm.com (pnqlwv041.amcc.com [10.48.19.141]) by denmail01.amcc.com (8.13.8/8.13.8) with ESMTP id vA2B1H6o011206; Thu, 2 Nov 2017 05:01:18 -0600 Received: (from rsahu@localhost) by apm.com (8.14.4/8.14.4/Submit) id vA2B1AGe006708; Thu, 2 Nov 2017 16:31:10 +0530 From: Rameshwar Prasad Sahu To: olof@lixom.net, tj@kernel.org, arnd@arndb.de Cc: linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, mlangsdo@redhat.com, jcm@redhat.com, patches@apm.com, Rameshwar Prasad Sahu Subject: [PATCH v2] ata: fixes kernel crash while tracing ata_eh_link_autopsy event Date: Thu, 2 Nov 2017 16:31:07 +0530 Message-Id: <1509620467-6679-1-git-send-email-rsahu@apm.com> X-Mailer: git-send-email 1.7.1 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When tracing ata link error event, the kernel crashes when the disk is removed due to NULL pointer access by trace_ata_eh_link_autopsy API. This occurs as the dev is NULL when the disk disappeared. This patch fixes this crash by calling trace_ata_eh_link_autopsy only if "dev" is not NULL. v2 changes: Removed direct passing "link" pointer instead of "dev" in trace API. Signed-off-by: Rameshwar Prasad Sahu --- drivers/ata/libata-eh.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) -- 1.7.1 diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index e4effef..ea20e0e 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c @@ -2264,8 +2264,8 @@ static void ata_eh_link_autopsy(struct ata_link *link) if (dev->flags & ATA_DFLAG_DUBIOUS_XFER) eflags |= ATA_EFLAG_DUBIOUS_XFER; ehc->i.action |= ata_eh_speed_down(dev, eflags, all_err_mask); + trace_ata_eh_link_autopsy(dev, ehc->i.action, all_err_mask); } - trace_ata_eh_link_autopsy(dev, ehc->i.action, all_err_mask); DPRINTK("EXIT\n"); }