Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp871106pxx; Tue, 27 Oct 2020 02:32:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvlnGxzQFqutrtFktSLxaNsuf6yA5015w+0yLlQduLuMI+KAdLrPzTz7LS7qIltHxosRsd X-Received: by 2002:a17:906:14d8:: with SMTP id y24mr1443510ejc.123.1603791141071; Tue, 27 Oct 2020 02:32:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603791141; cv=none; d=google.com; s=arc-20160816; b=MuiWv+V8MkKOdqzgf215rFeuFnUtaC6JlD6pKtUZeWXu+RjTA8kYUBqsBdsCb2xgHp ISnmbEKve71RyIYNCCznhd2WOEwyPGrTcCPzAZPIacY+Ed7y975xLCryB4qUJxe9ijHu Cbo4lTnJpcBvxv+Qp8idCXKlM+k5X97Cww79JEhVhMRKg3Ua5mpYCAMOmyjP6BZpvy/X ClQAEGFw0SjEElgJ+ScMqIvBLgnlwYEp9t8ZoAicXuuNRKKGtg2fd+qJ6ypiO74Z/SJ3 tW1ahSpXqupD9kChwoJbUI9N5r6+i1tXHYANTA5ZOlkC1Ir417sB7/eur9V74QYB4+40 VaDg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZlLuhbayTmYoD3d6R7U8P+qjzLS2dF/elPOSDkyJx/c=; b=VymLtY84qhTPMxVOdcHcDG0z2wwuFZoLRvO+wku0QzwRhbewFE8zZ3GuHo9ZYg7JwQ jIW06LQN0/n4pTmpipyNVOTiehwKWO/FFCiIPCxux10faDBwzbG7iIbWeG7ilse8avTl UCNd4uS4DzpF8U1zt3g/ylWOetkoASzrbJ6BDE8QN4jeCF59ImDjsurwYpGFgcvS0WCI nJav1c9r6/21GglckJzQjMBAlvqm4EVIlbj0acFORGLTpMC9/yLbVKMi4pjejSjfP7Pw FnEXUmw8deJ0e3WAV7qsSm6wDEbuxvgLEG1GSTwbeh1JxjYvnAvfQ3Xn+Hk74L+eO/Cn 3QFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bdoCtbgz; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p25si638294ejc.412.2020.10.27.02.31.58; Tue, 27 Oct 2020 02:32:21 -0700 (PDT) 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=bdoCtbgz; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2409169AbgJZXul (ORCPT + 99 others); Mon, 26 Oct 2020 19:50:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:49198 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409041AbgJZXuJ (ORCPT ); Mon, 26 Oct 2020 19:50:09 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 034AE20874; Mon, 26 Oct 2020 23:50:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756209; bh=fKL3J8CPBrYLpzUa1ey64r5goiIaDA6PJaNOwE4RVXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bdoCtbgzgEwsvQNMaxpT3653tDxli6JnZpGZJ5RMeN3LDEbMvjrRQd8S+pGiNjWAM WqHs4d43euKtdh8B3DDIMSe9+EAlee/nYTeN82PuCfbaFw7GmN5LKzriny7XKK8ggr ybBjVIZJmDZQn/GwEIactwWboBHH/9LphO/WOeLc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Madhuparna Bhowmik , Ulf Hansson , Sasha Levin , linux-mmc@vger.kernel.org Subject: [PATCH AUTOSEL 5.9 051/147] mmc: via-sdmmc: Fix data race bug Date: Mon, 26 Oct 2020 19:47:29 -0400 Message-Id: <20201026234905.1022767-51-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026234905.1022767-1-sashal@kernel.org> References: <20201026234905.1022767-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 49dab9f42b6d6..9b755ea0fa03c 100644 --- a/drivers/mmc/host/via-sdmmc.c +++ b/drivers/mmc/host/via-sdmmc.c @@ -1257,11 +1257,14 @@ static void __maybe_unused via_init_sdc_pm(struct via_crdr_mmc_host *host) static int __maybe_unused via_sd_suspend(struct device *dev) { struct via_crdr_mmc_host *host; + unsigned long flags; host = dev_get_drvdata(dev); + spin_lock_irqsave(&host->lock, flags); via_save_pcictrlreg(host); via_save_sdcreg(host); + spin_unlock_irqrestore(&host->lock, flags); device_wakeup_enable(dev); -- 2.25.1