From patchwork Tue Nov 3 20:36:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 317112 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9505EC2D0A3 for ; Tue, 3 Nov 2020 21:03:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 60523205ED for ; Tue, 3 Nov 2020 21:03:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437437; bh=MXGjkdP4xr4nOyOFnNoA6nDzkUpX2aqE63/WbExOqi4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=SVpiShOmRV1FB5bqgW1fYvrZx5FETLSuyV5d/ZHxXVzu0qf8ptscf2aM7yAN7Nud9 33Do2fNRXY0KYWSFx4bkahz1F60zEn2xn/AOAx55ZswypET1wcB9CVIcrEoMmxrRYM FdGkb5ZtXvQeNxlrRhkCoDpvzFAwhKz/kHvZA8Zg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387907AbgKCVD4 (ORCPT ); Tue, 3 Nov 2020 16:03:56 -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 Precedence: bulk List-ID: X-Mailing-List: stable@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);