From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.7 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF829C31E45 for ; Thu, 13 Jun 2019 16:17:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C10F32147A for ; Thu, 13 Jun 2019 16:17:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560442651; bh=TAqnMvgMqJKjaJd9W6Ij2T3guZh8sir0EK5c3BaNcdA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=jKIdeprfG9yUd+jgqdNYWAWQUoLbUmA2w1CaDf8sIudIzznZiGFMJYKeR65JhNR6W x9itAEXuUiaOk2SmaoWfGxMeNODDHnBdalxShxOAvCz8QgUFucCNkkGzy/cJy6ksF8 UthEnqMYaeAXBkT2cEMI437TiPwGgUJ9d6wAgQLU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388478AbfFMQRF (ORCPT ); Thu, 13 Jun 2019 12:17:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:58394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731142AbfFMIlG (ORCPT ); Thu, 13 Jun 2019 04:41:06 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 76BFF21473; Thu, 13 Jun 2019 08:41:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560415266; bh=TAqnMvgMqJKjaJd9W6Ij2T3guZh8sir0EK5c3BaNcdA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hjj8r1YWfwcQ5bZfOm+8J6aMh5feFqq4VqyFQZPJ5ycmAB06wP4IW15J/XM3tvRLX kWWKrmJqGvjFXocEYOXlaquozrGkm41Vhc5L/VCobEJ5FV97V3hneFS0czwlnBIGqm GygWnjmrjQGN8aL9khJLvYMqG+t6NmaV9qoxFYHg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liwei Song , Takashi Iwai , Sasha Levin Subject: [PATCH 4.19 063/118] ALSA: hda - Register irq handler after the chip initialization Date: Thu, 13 Jun 2019 10:33:21 +0200 Message-Id: <20190613075647.522443235@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190613075643.642092651@linuxfoundation.org> References: <20190613075643.642092651@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit f495222e28275222ab6fd93813bd3d462e16d340 ] Currently the IRQ handler in HD-audio controller driver is registered before the chip initialization. That is, we have some window opened between the azx_acquire_irq() call and the CORB/RIRB setup. If an interrupt is triggered in this small window, the IRQ handler may access to the uninitialized RIRB buffer, which leads to a NULL dereference Oops. This is usually no big problem since most of Intel chips do register the IRQ via MSI, and we've already fixed the order of the IRQ enablement and the CORB/RIRB setup in the former commit b61749a89f82 ("sound: enable interrupt after dma buffer initialization"), hence the IRQ won't be triggered in that room. However, some platforms use a shared IRQ, and this may allow the IRQ trigger by another source. Another possibility is the kdump environment: a stale interrupt might be present in there, the IRQ handler can be falsely triggered as well. For covering this small race, let's move the azx_acquire_irq() call after hda_intel_init_chip() call. Although this is a bit radical change, it can cover more widely than checking the CORB/RIRB setup locally in the callee side. Reported-by: Liwei Song Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/pci/hda/hda_intel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 9bc8a7cb40ea..45bf89ed31de 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1883,9 +1883,6 @@ static int azx_first_init(struct azx *chip) chip->msi = 0; } - if (azx_acquire_irq(chip, 0) < 0) - return -EBUSY; - pci_set_master(pci); synchronize_irq(bus->irq); @@ -2000,6 +1997,9 @@ static int azx_first_init(struct azx *chip) return -ENODEV; } + if (azx_acquire_irq(chip, 0) < 0) + return -EBUSY; + strcpy(card->driver, "HDA-Intel"); strlcpy(card->shortname, driver_short_names[chip->driver_type], sizeof(card->shortname)); -- 2.20.1