Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp634539pxx; Mon, 26 Oct 2020 17:36:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+ggY0rHzClKzWt2jOE1Q1fyC6tHk+m3j+VSEsjyAUkvQTERr24ImD/U+0g91cQ0gUAUIX X-Received: by 2002:a17:906:7696:: with SMTP id o22mr17155858ejm.269.1603758967640; Mon, 26 Oct 2020 17:36:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603758967; cv=none; d=google.com; s=arc-20160816; b=A96iteRyJyVf7o3/zRWkcV2Th9ewnI6LBREJVYvWpk6WGUaHlQ6GXki33M4cyCy0vu Clh8vx0XIrpJ0dITVQmhdFWyZHmNU0DHfA9MKwEtYOjBn3S7pwJbo9PGdzL2v/J5OKOZ 7h9HZXJyYdG4owBNCa76N6ffSwznTJq7Nw0p+Xs5BfjcyhK+2BmbZeP2tycAQJL+F+n8 W3Tdp4eaxQ50m6gHrzUF9PcTDR1cc0i7/2KhuAXwqyFxPa/hHaYyNd09+lDRhZ++q783 vy9HKFv7l1VqmTTCpWyUsHk8StZTAQ6e05/mimkNffoheSXvqhpU1Krk51wQV3Th0a9Z TsAQ== 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=Cz+UWupFbwzv1UG/GZPyOVeHqLr+2TjgU2WwTBPYOFg=; b=q5PJEykPAS62xDHD2ndiDjhmHAa8lEEu/hoEfeNKNqhXScjfYlBdOcyZqhAmNo1USF lDgSqTvAfruIiVBR2U5DHW9L7N/BI7MNFxVGkult3KsOncPHuqmwVcUGOdLS1++S5vwP TdSlG3m8efeZW9yj8wj7NT8ujSn+NlyDMDYLyzwnrcDjUYrLWD9oHV+v/iHkuSP7zgW6 QIJ9SfV2q9Fq0e9eP/PaOZORJsSKuYhizevdnPk9YMBzrlZZII8XBWtI+wVQgVaKe2Pt RKGKzelJkmmeWgWiMYO0flpw/po7TzTZ8SDPzo98l1mPZKx/GuNyoMOqQidP983SvNCe Rs+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZmGY3bSV; 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 c21si4058945edy.280.2020.10.26.17.35.46; Mon, 26 Oct 2020 17:36:07 -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=ZmGY3bSV; 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 S2441249AbgJ0AVz (ORCPT + 99 others); Mon, 26 Oct 2020 20:21:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:33688 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2410974AbgJZXzt (ORCPT ); Mon, 26 Oct 2020 19:55:49 -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 7E1D320B1F; Mon, 26 Oct 2020 23:55:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756549; bh=aIiTGYggak3CM+beeinXqt9y0SWPQVk1XwmAovTDKd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZmGY3bSVixfCbpnj/Z4L7WfGMEMzHLtcTleejhFVVdICO2iO7lH02i4sJzi4vYQDp J1zcOOpJ4KPsURf6cFPDBTFBIdhIll1X0TRoUGqrw6Y/khqu1enfzQeQ9rh8lDhUct LIVlvcXghxLYBFHH/htx3SxLg7lm/r3Rv9aJylHQ= 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.4 26/80] mmc: via-sdmmc: Fix data race bug Date: Mon, 26 Oct 2020 19:54:22 -0400 Message-Id: <20201026235516.1025100-26-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026235516.1025100-1-sashal@kernel.org> References: <20201026235516.1025100-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 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.25.1