Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3213465pxb; Mon, 9 Nov 2020 05:45:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWEqT/W2JBuhG5jHkaT7K+cghzzsWs9g+EBoa0bMZoSjAAZo6pcZcvFWnGOn+kdv8faT8K X-Received: by 2002:a17:906:114b:: with SMTP id i11mr14511719eja.106.1604929531759; Mon, 09 Nov 2020 05:45:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604929531; cv=none; d=google.com; s=arc-20160816; b=iqPNG3QyJEg3PTy257OL6g/ZRBOTtQfwmoVkv1x37lAB6O9Wn2h7MA7QYuVVPKq0Ks sAQMdqNdmqL7RYV+CmvcHM7EUvIR+tbwB+NvxbwKw7AqgDmyVNUKcAne4JPH23Dgfbmb mi9J4z60cpv5BH2VtJGatV3FOUNHY+88hm1fFWJpBRc6MHMz4I9z7dY2b9cJp4M8nF83 bUevYnIIZLx34MpYmbys9Ctj/SAZlK9DYNYo85m7t8lTrGXO0MunhTkCHtqbvS+E6bgX OLQDs5UsZnXiEk6EtYCS1fKYvaJwBcxKLU5errfWCtlC9A+nigC0EIFSWAsOuJ+UFnDJ sqVg== 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=yaoSjL4izdUjHLFyyz17h1lwWHavDUzGJZM81pE0IVM=; b=sTVprG7D63cjbRdHpYqEwkFYzQZ+9SAAADHS4gkqzrmPDswhGc7h+pgkMB9NS07F2M WmdXkW9MnT7izc0rmwwm3qB/T6XR3D+3WoNHT3sQjfmf0scci6AmUYbsMdJJmXd4QfUb eksbvJqrhzzMaKaz0WnaFRccU/OHjqr0KhM0h6A3v0FAu1nKDdBZKyl5LzSm6MPbGE/2 J7RxFgAyWXOo01zw8K3kM/p73mgpJ5jzcMEbwPo82bszosynoAdgqgPOTkji6X9fU1mI hnYuKWl1ll/JxokVlmM4FH2dxvLs/yX+CK3c9V/CmAt19WrTZvaPgmhXKiwWNnBe/REW NJ5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=btEtDOw1; 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 dn22si7858513edb.239.2020.11.09.05.45.08; Mon, 09 Nov 2020 05:45:31 -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=btEtDOw1; 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 S2387825AbgKINma (ORCPT + 99 others); Mon, 9 Nov 2020 08:42:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:54972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730528AbgKINAu (ORCPT ); Mon, 9 Nov 2020 08:00:50 -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 5E7732084C; Mon, 9 Nov 2020 13:00:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604926850; bh=Q6bDaJS34z/8dLa28ozlSl9YUGCmH0TY7XAVGCgRy9Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=btEtDOw1fxqg8NjbLrcfpzSdDDpAkNNVjKDhZ9ip56Y71Lp+Dcr3PECHe+Uia9HIB BJV8oGODuAzzt1C1oPaZBdQHt6SckFapROit776fFUgk9UQCskmKVQpWh7TxR95Q3C t0XMuw4yDPT/e21pei+eLat18gKgj54nTOmQUkzw= 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.9 026/117] mmc: via-sdmmc: Fix data race bug Date: Mon, 9 Nov 2020 13:54:12 +0100 Message-Id: <20201109125026.896527896@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125025.630721781@linuxfoundation.org> References: <20201109125025.630721781@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 63fac78b3d46a..b455e9cf95afc 100644 --- a/drivers/mmc/host/via-sdmmc.c +++ b/drivers/mmc/host/via-sdmmc.c @@ -1269,11 +1269,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