From patchwork Fri Mar 27 13:31:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 6107071 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 C23BB9F399 for ; Fri, 27 Mar 2015 13:31:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1B3F4203F3 for ; Fri, 27 Mar 2015 13:31:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F23F92038E for ; Fri, 27 Mar 2015 13:31:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752709AbbC0NbQ (ORCPT ); Fri, 27 Mar 2015 09:31:16 -0400 Received: from cantor2.suse.de ([195.135.220.15]:58364 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752561AbbC0NbP (ORCPT ); Fri, 27 Mar 2015 09:31:15 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 75D96ABA2; Fri, 27 Mar 2015 13:31:14 +0000 (UTC) From: Hannes Reinecke To: James Bottomley Cc: Christoph Hellwig , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCHv2] am53c974: Fix crash during modprobe Date: Fri, 27 Mar 2015 14:31:12 +0100 Message-Id: <1427463072-99968-1-git-send-email-hare@suse.de> X-Mailer: git-send-email 1.8.5.2 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, 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 On systems with shared interrupts the interrupt routine might be called as soon as the interrupt is enabled. As this might happen before pci_set_drvdata() is called the system would crash. Reported-by: Andreas Brogle Tested-by: Andreas Brogle Signed-off-by: Hannes Reinecke --- drivers/scsi/am53c974.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/am53c974.c b/drivers/scsi/am53c974.c index a6f5ee8..beea30e 100644 --- a/drivers/scsi/am53c974.c +++ b/drivers/scsi/am53c974.c @@ -476,6 +476,8 @@ static int pci_esp_probe_one(struct pci_dev *pdev, goto fail_unmap_regs; } + pci_set_drvdata(pdev, pep); + err = request_irq(pdev->irq, scsi_esp_intr, IRQF_SHARED, DRV_MODULE_NAME, esp); if (err < 0) { @@ -496,8 +498,6 @@ static int pci_esp_probe_one(struct pci_dev *pdev, /* Assume 40MHz clock */ esp->cfreq = 40000000; - pci_set_drvdata(pdev, pep); - err = scsi_esp_register(esp, &pdev->dev); if (err) goto fail_free_irq; @@ -507,6 +507,7 @@ static int pci_esp_probe_one(struct pci_dev *pdev, fail_free_irq: free_irq(pdev->irq, esp); fail_unmap_command_block: + pci_set_drvdata(pdev, NULL); pci_free_consistent(pdev, 16, esp->command_block, esp->command_block_dma); fail_unmap_regs: @@ -530,6 +531,7 @@ static void pci_esp_remove_one(struct pci_dev *pdev) scsi_esp_unregister(esp); free_irq(pdev->irq, esp); + pci_set_drvdata(pdev, NULL); pci_free_consistent(pdev, 16, esp->command_block, esp->command_block_dma); pci_iounmap(pdev, esp->regs);