From patchwork Sat Aug 1 17:19:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 6922541 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 95B7E9F358 for ; Sat, 1 Aug 2015 17:20:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C0FD720501 for ; Sat, 1 Aug 2015 17:20:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A7EC8202B8 for ; Sat, 1 Aug 2015 17:20:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751423AbbHART5 (ORCPT ); Sat, 1 Aug 2015 13:19:57 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:36469 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751015AbbHART4 (ORCPT ); Sat, 1 Aug 2015 13:19:56 -0400 Received: by pachj5 with SMTP id hj5so59009709pac.3; Sat, 01 Aug 2015 10:19:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rRjZmb2CfVHPog0pxui7qlUOzLVIIxbVqjMnR6Ec9qU=; b=PasQ4XCaiIdcfV0opFpyUKd9yvag7uyim4IIDsnue7cBXvXGdrYNIXZrVGdIR99spr uZX5N96eGxahhwFYs7ZsW0NoxJixgd6J4jgRjxQAIE2QUp/kMem9KPjtdVq2bo6ET+dG /J2VkAeEmqvLcRUudc0YVffxSVE5KywPZXM77PbUircNZkW6sR60/90na0zhGTun6yV0 qRAe1k8OGoUV+or5uefJYPbeRXOMHvYc3iYLOst+E7qa9nD4RFkVXZjcDd9im1zK9WJB XGTHL5B/FQRbARshPDs3rMjU3yRHATJAuqUEQiYdZI63XnSPqf7AVk4IisSCigcAavJI peiA== X-Received: by 10.66.249.101 with SMTP id yt5mr19783677pac.116.1438449596076; Sat, 01 Aug 2015 10:19:56 -0700 (PDT) Received: from localhost.localdomain (KD113159139091.ppp-bb.dion.ne.jp. [113.159.139.91]) by smtp.gmail.com with ESMTPSA id tm3sm12259153pac.44.2015.08.01.10.19.51 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Aug 2015 10:19:54 -0700 (PDT) From: Akinobu Mita To: linux-scsi@vger.kernel.org Cc: Akinobu Mita , Vinayak Holikatti , "James E.J. Bottomley" , Christoph Hellwig , Dolev Raviv , Sujit Reddy Thumma , Subhash Jadavani , Hannes Reinecke , Sahitya Tummala , Yaniv Gardi , linux-kernel@vger.kernel.org Subject: [PATCH v2 4/6] scsi: ufs: prevent IRQ handler accessing already freed hostdata Date: Sun, 2 Aug 2015 02:19:18 +0900 Message-Id: <1438449560-4106-5-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1438449560-4106-1-git-send-email-akinobu.mita@gmail.com> References: <1438449560-4106-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As UFS driver registers IRQ handler as a shared IRQ, when CONFIG_DEBUG_SHIRQ=y, an extra call will be made while unregistering the IRQ handler. Unfortunately, the extra call will accesses already freed hostdata. This is because devm_request_irq() is used to register IRQ handler so that it will be unregistered automatically on driver remove, but the hostdata has already been freed at this time. This fixes it by explicitly registering/unregistering IRQ handler on driver probe/remove. Signed-off-by: Akinobu Mita Cc: Vinayak Holikatti Cc: "James E.J. Bottomley" Cc: Christoph Hellwig Cc: Dolev Raviv Cc: Sujit Reddy Thumma Cc: Subhash Jadavani Cc: Hannes Reinecke Cc: Sahitya Tummala Cc: Yaniv Gardi Cc: linux-scsi@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/scsi/ufs/ufshcd.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index e25f919..d425816 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -5361,6 +5361,7 @@ void ufshcd_remove(struct ufs_hba *hba) scsi_remove_host(hba->host); /* disable interrupts */ ufshcd_disable_intr(hba, hba->intr_mask); + ufshcd_disable_irq(hba); ufshcd_hba_stop(hba); ufshcd_exit_clk_gating(hba); @@ -5611,13 +5612,9 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) ufshcd_init_clk_gating(hba); /* IRQ registration */ - err = devm_request_irq(dev, irq, ufshcd_intr, IRQF_SHARED, UFSHCD, hba); - if (err) { - dev_err(hba->dev, "request irq failed\n"); + err = ufshcd_enable_irq(hba); + if (err) goto exit_gating; - } else { - hba->is_irq_enabled = true; - } /* Enable SCSI tag mapping */ err = scsi_init_shared_tag_map(host, host->can_queue); @@ -5668,9 +5665,9 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) out_remove_scsi_host: scsi_remove_host(hba->host); exit_gating: + ufshcd_disable_irq(hba); ufshcd_exit_clk_gating(hba); out_disable: - hba->is_irq_enabled = false; ufshcd_hba_exit(hba); out_error: scsi_host_put(host);