Received: by 2002:a05:6622:f08:0:0:0:0 with SMTP id l8csp4478742ivc; Tue, 3 Nov 2020 13:05:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwR5SEaguNmffFJDt9a7H0x7wgmAIgriRNlYNjdnhs/e+UrKx7GYg8S6QYAY6Gf+Y9sKXrr X-Received: by 2002:a17:906:660f:: with SMTP id b15mr22754049ejp.333.1604437540841; Tue, 03 Nov 2020 13:05:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604437540; cv=none; d=google.com; s=arc-20160816; b=NIQZp0RPIbqZHrklRDQK6CbwPizcWOON++UMUxwRhhFmxIu5IR0QqlOSBDI4uY/U2L 2KWNzTeiDgNLyMEZTDYEpeeXi7WYLMZJ3ABM1WoDkQ/tAerQuCDb2HJQFW1mBnjviA82 Km+otAhZmAVGwVm7tgmZLVRQPbxfMVtcaLHTpMOxuc2wXo6u520dx9rwgNF992jTDArB 1DvRbgcPfuMAoxu9oa+oiGtXx94hCcAC77c7tUcUUG0a0eKf073qOAE90jl7WD+o1Jd0 zr597FX5PbMugQuSDuVjYWVDC6vHqpZ9qSEkAfcDdRQ3VZCT3HscWLP95NZ3xGMD/Uyo iqFg== 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=xMPy6KPahg5ydFUwb3FplSZS3hdxhBnxN5+s7wL2EDE=; b=OPNo1JUfKWFsMyJnwBV94l1kMTev73dzHNLZiRewK5dTIQ0K1izsYeK27+LR2AqXnq BE4leptXfMWnrTzbo/OXrK7vqLDM373VC5cu4NzlgvK0MXDTDdOOo+PABvK8V9XUabe/ Z6Epudm/ZnrWa6WH3Ej8U5nF3TTWSyhHqn1KBgKYbsAMSvSf24Bya+FhXzQ0j0ByDdx1 zSSMZZAuPuKw9EKk5t15t0yltTRtXtB8NekPVq2ymIHRMxeSYif3xZzAgeubRGjkeo3f DetGpH06Wa1B0yCAiA9sqT9o1v9CByAz3LR2NincYDF9Qa0eYOxGRhC35InwrVdFKTqu ZPsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UPDucQqZ; 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 o60si14116016eda.61.2020.11.03.13.05.17; Tue, 03 Nov 2020 13:05:40 -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=UPDucQqZ; 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 S1732333AbgKCVEA (ORCPT + 99 others); Tue, 3 Nov 2020 16:04:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:41754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387903AbgKCVDz (ORCPT ); Tue, 3 Nov 2020 16:03:55 -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 C0630206B5; Tue, 3 Nov 2020 21:03:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437435; bh=MXGjkdP4xr4nOyOFnNoA6nDzkUpX2aqE63/WbExOqi4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UPDucQqZ7qyVLt3HYyZaklQaJv4KKEe6JgLXvNLKg9kLJBoWpSxBvewChiQxEZ+Vg yy3dyHlWKfHvIZH0kAtG0HoH6GF0zMmL9D6/iPjkmvV1JeeehzIIUpoTOHHxxJhnVJ MKVPsmZfy6Jge6Mt7rUI1w9488val7v8s3QSranU= 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 4.19 074/191] mmc: via-sdmmc: Fix data race bug Date: Tue, 3 Nov 2020 21:36:06 +0100 Message-Id: <20201103203241.279879792@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203232.656475008@linuxfoundation.org> References: <20201103203232.656475008@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 246dc6255e696..9fdb92729c28b 100644 --- a/drivers/mmc/host/via-sdmmc.c +++ b/drivers/mmc/host/via-sdmmc.c @@ -1273,11 +1273,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