Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp831160pxb; Tue, 3 Nov 2020 13:48:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJw9vYTkZKkY24Yuo1ZBbUz14e83PK1t19HR6T7mMmREAkrr6bxCTWoAJFcD+Gw230oE5x6U X-Received: by 2002:a17:906:3a1a:: with SMTP id z26mr21536873eje.519.1604440106764; Tue, 03 Nov 2020 13:48:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604440106; cv=none; d=google.com; s=arc-20160816; b=JVZeHu08AVNizH2Qtajalu/dJtX42KsKFWZ2qpTaRogSCSEsv0pwk6gPnLKSoRLJIp P7QCVWzuCNQaG2SRosKLP6J4nL5NV6gCP2aJnoG6JKZ3ALgzbYDxYXFJbNkt9T0lD8Vc iloqV0MKL2BOk1IXg8qicX1HJn+ZjsuEWi1pqe9J921tDKDhv7lgimzI3Dje2JRh3NVa Y6GsEcN9j04Lfs7aRNH/heD0947B4+bDYURFXET/3N+E6iaOmTT8kmN35iecyWx01DkP FYjFIqkbkND1C2+L5fHzYfmWw9fOdH9DfYOVsmMiP4YVBGcO2WFSFEy4gvwAUsRwwV5p r7aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IcHELx0QUNd4wlj5NKVV5XUk5O9oqpZ9ZeZ3r7T+UkU=; b=Ra24IbpBldnmHHqV0Wouwjbrk6fL15dwoqc1UMFi1gC1lwDlR+ltl0YSNUjt9u1IAp 8Y4+ONScCjYG5yo0pm0rNqC7d84alX8bPRR0ww9AwbgojHCiiL9/plUQg9NQWnfDuyMW sp+24qCiIpcYvFMMCPhSXJJ4MELQ9tfxj+p1OmSPM3km5wcjaUzfJ4nzVa1KJWGtXmNQ tiaTm5471sx+NfmBDShCZH0WFicinPzUYE235iUafCjWN8nIvOx6+Xv3slmWEH0Umet9 jp7HVyXNCUO9CN+Hr/iKGb8TI1efackZ3F0U+aNy+658QsG5hE/NFGJBIduL4hDyYisM cC+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jz6Hdxe7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j13si13632226edj.549.2020.11.03.13.48.04; Tue, 03 Nov 2020 13:48:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jz6Hdxe7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733169AbgKCVns (ORCPT + 99 others); Tue, 3 Nov 2020 16:43:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:53438 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730273AbgKCUyZ (ORCPT ); Tue, 3 Nov 2020 15:54:25 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 51D1122226; Tue, 3 Nov 2020 20:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436864; bh=OZFFI1f285A+iMr0hjLUkaeUgtNpZDX8zMj//uoFsjE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jz6Hdxe7xnkll8kB2GY40rRwCapzbeyhc0veM2rCRm5wACGDiwEnKadkVEzmKUypH 88eLC2XO+bD44bSZZU+smUYE3pbywHR/T5npwLm/4Zu18pGHB6LomljR8BiVbNxp9s zNv0CRrsX+qwpz/8Ra7b8Ua+8OCVBHA1MKQv+LLk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Madhuparna Bhowmik , Ulf Hansson , Sasha Levin Subject: [PATCH 5.4 045/214] mmc: via-sdmmc: Fix data race bug Date: Tue, 3 Nov 2020 21:34:53 +0100 Message-Id: <20201103203254.326872826@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Madhuparna Bhowmik [ Upstream commit 87d7ad089b318b4f319bf57f1daa64eb6d1d10ad ] via_save_pcictrlreg() should be called with host->lock held as it writes to pm_pcictrl_reg, otherwise there can be a race condition between via_sd_suspend() and via_sdc_card_detect(). The same pattern is used in the function via_reset_pcictrl() as well, where via_save_pcictrlreg() is called with host->lock held. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Madhuparna Bhowmik Link: https://lore.kernel.org/r/20200822061528.7035-1-madhuparnabhowmik10@gmail.com Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/mmc/host/via-sdmmc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mmc/host/via-sdmmc.c b/drivers/mmc/host/via-sdmmc.c index 8d96ecba1b553..d12a068b0f9ed 100644 --- a/drivers/mmc/host/via-sdmmc.c +++ b/drivers/mmc/host/via-sdmmc.c @@ -1259,11 +1259,14 @@ static void via_init_sdc_pm(struct via_crdr_mmc_host *host) static int via_sd_suspend(struct pci_dev *pcidev, pm_message_t state) { struct via_crdr_mmc_host *host; + unsigned long flags; host = pci_get_drvdata(pcidev); + spin_lock_irqsave(&host->lock, flags); via_save_pcictrlreg(host); via_save_sdcreg(host); + spin_unlock_irqrestore(&host->lock, flags); pci_save_state(pcidev); pci_enable_wake(pcidev, pci_choose_state(pcidev, state), 0); -- 2.27.0