From patchwork Wed Oct 25 10:22:56 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: 10026519 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 C08E66032C for ; Wed, 25 Oct 2017 11:12:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BECB128B4B for ; Wed, 25 Oct 2017 11:12:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B399C28B4F; Wed, 25 Oct 2017 11:12:11 +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 5CB7628B4B for ; Wed, 25 Oct 2017 11:12:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750862AbdJYLMK (ORCPT ); Wed, 25 Oct 2017 07:12:10 -0400 Received: from [198.137.200.161] ([198.137.200.161]:60082 "EHLO denmail01.amcc.com" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750763AbdJYLMI (ORCPT ); Wed, 25 Oct 2017 07:12:08 -0400 X-Greylist: delayed 2908 seconds by postgrey-1.27 at vger.kernel.org; Wed, 25 Oct 2017 07:12:08 EDT Received: from apm.com (pnqlwv041.amcc.com [10.48.19.141]) by denmail01.amcc.com (8.13.8/8.13.8) with ESMTP id v9PAN6CR003047; Wed, 25 Oct 2017 04:23:07 -0600 Received: (from rsahu@localhost) by apm.com (8.14.4/8.14.4/Submit) id v9PAN0lG011569; Wed, 25 Oct 2017 15:53:00 +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] ata: fixes kernel crash while tracing ata_eh_link_autopsy event Date: Wed, 25 Oct 2017 15:52:56 +0530 Message-Id: <1508926976-11467-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. Given that the trace routine requires only the link info, pass the link info instead of passing dev pointer to fix this kernel crash. Signed-off-by: Rameshwar Prasad Sahu --- drivers/ata/libata-eh.c | 2 +- include/trace/events/libata.h | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) -- 1.7.1 diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index e4effef..ab50e7d 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c @@ -2265,7 +2265,7 @@ static void ata_eh_link_autopsy(struct ata_link *link) 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(link, ehc->i.action, all_err_mask); DPRINTK("EXIT\n"); } diff --git a/include/trace/events/libata.h b/include/trace/events/libata.h index 2fbbf99..eff035e 100644 --- a/include/trace/events/libata.h +++ b/include/trace/events/libata.h @@ -276,9 +276,10 @@ TRACE_EVENT(ata_eh_link_autopsy, - TP_PROTO(struct ata_device *dev, unsigned int eh_action, unsigned int eh_err_mask), + TP_PROTO(struct ata_link *link, unsigned int eh_action, + unsigned int eh_err_mask), - TP_ARGS(dev, eh_action, eh_err_mask), + TP_ARGS(link, eh_action, eh_err_mask), TP_STRUCT__entry( __field( unsigned int, ata_port ) @@ -288,8 +289,8 @@ ), TP_fast_assign( - __entry->ata_port = dev->link->ap->print_id; - __entry->ata_dev = dev->link->pmp + dev->devno; + __entry->ata_port = link->ap->print_id; + __entry->ata_dev = link->pmp + link->device->devno; __entry->eh_action = eh_action; __entry->eh_err_mask = eh_err_mask; ),