Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1861497pxa; Mon, 3 Aug 2020 00:32:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyC4SfeBdCWgRp7dgB+BiyCXpXpydBc9jsbBx6TMLG6KNjmu/b6MLbrrCPkv5Nh7DO32awd X-Received: by 2002:a17:906:c24e:: with SMTP id bl14mr15144393ejb.285.1596439953568; Mon, 03 Aug 2020 00:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596439953; cv=none; d=google.com; s=arc-20160816; b=PhtLsgJFReb/iJCD7K+H15hy+DdOAAqGZtTik8PE5nXjbWrYGcbld47rH3/3pK8X6X zv4GgEZVsyhD04xbUVQt/NYcnow/8Qtx9maWYxmVQvIxDWzp9dUKstmDrYxpwwvNefqH IWO8hTw6jjnopnpjGqXb/zX/p9sIAf7+oEdk4YYp9CDt1sfi6G+fRGCCJ/1UvIzKuIGb TD9nJ33fFOvFFXtmb0XjYaNtLh/9yfSzr7C9TZazaTmigAFSijwRHe9oTsuBqK6M+qCO /9hEmDjjHTRCcGWGGTUPUegDjLMBDbx3ONr3L8cbHQxL14DmWLheht4lvzu2UYpAMCH4 VmGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=tlFv8p7PrXE4U8lsxSb50hSc4sf1CRTi/2In4NKS0vI=; b=NfgOXuJh6EtsPJFslcL5g9TOLzvwLNw4fsJrJXGUMdzDhQqEfV1NnNFkMiZSZqPp4S wHobQ93vaEhYDtsKWrvhEhF4FWmtG3RUhaxWIJ+lRhdAAxTnGk9k0iKjR8RoOa709Le7 OopfXHKLGMtUiAvGILxlkvM8w14ZnmswJ2nMlBMIIzliJ7SrYDBr9tulicSoYIMFdVNX UZhxs6nCNriPEWshdkX9dn3nEjf87M5Mq93RnW+GqeKTWb5G+jexJ/IWTJ9q1hsHAYJL L4s2eBwxgFhvruh2ADA5RW1HHIwnxpI9p/DMmuCwprI5Fz0ibaVFNTi1xOH80t7hjWv6 o4LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=M2aThiXp; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m23si5161790edq.564.2020.08.03.00.32.10; Mon, 03 Aug 2020 00:32:33 -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=@gmail.com header.s=20161025 header.b=M2aThiXp; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725992AbgHCH3I (ORCPT + 99 others); Mon, 3 Aug 2020 03:29:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725840AbgHCH3I (ORCPT ); Mon, 3 Aug 2020 03:29:08 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EDDAC06174A; Mon, 3 Aug 2020 00:29:08 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id o1so20286506plk.1; Mon, 03 Aug 2020 00:29:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=tlFv8p7PrXE4U8lsxSb50hSc4sf1CRTi/2In4NKS0vI=; b=M2aThiXpuOYXtob+rSfmzq8jLCsn9uVeQHWSRRKPyEHhOW1DmGNsbIJzr70VA9ZRuq zoDvmdMFS8e1VWlw5ZaK9py20GqaMtKUmO3+yR7I9tDiD1Xbs3UwfNyN4dLtTVfT7Lsh o/OVznuBrWxbxDgsVUkrOSttpuUFHwCnbvLE4WOdHoVSPKDzymFNhCSNJ19x3uyUw6qV 4h2+2mdYq8zAdzGvSf9vglWxzMR687h7fPoCHNNfK7rW2aqSYvAl5N2ycKgRumHaJUaX LKIulzL9iZz/lRmMAcYIUqcIloUy6NUtLm0kAlbIMxqP+i+zYNwcihLjROjxHLh/8tm9 dTvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=tlFv8p7PrXE4U8lsxSb50hSc4sf1CRTi/2In4NKS0vI=; b=d4IxYyxdhSR4OoiR/4tVfJkSGQoq6NhoMhxfzYKkXxbDXLbTkHUlt6IeTT1q2pc62l T8Olpi16RRRivvDTiL3EvYex/EgFr2K8uRQKUU0DRPIBhv2LzyOjdJ7BhboAczBk18ia kM6ZAfC5R5DiNe6cvGmtITsv+6Ry8Jl6VSYIsar+2TuC86XcYZlHxjHRX6lnbw/BU5Yx kcZJLlZGTFf03IvhCld8m7r7yEcdMlCss+FL0ltklbODyGXdXujnm2WUQnvEVZK7lR1Z QzkfDgW183MV8rqZvPgNeaQd67ka/eYM4v0syajMT+9Kpia7mQJR7LS6aGt+RAUuCZhn zqBw== X-Gm-Message-State: AOAM533LX3w24iscVul2WAkitajcCgjNDhLCaEzB1DSJQhVhzEIYaszs 620LSAXfUbLgGktw87mBSA== X-Received: by 2002:a17:90a:a58d:: with SMTP id b13mr16997327pjq.55.1596439747998; Mon, 03 Aug 2020 00:29:07 -0700 (PDT) Received: from localhost.localdomain ([2402:3a80:ce2:8573:b0b2:951:c50:ed47]) by smtp.gmail.com with ESMTPSA id o10sm16648105pjo.55.2020.08.03.00.29.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 00:29:07 -0700 (PDT) From: madhuparnabhowmik10@gmail.com To: brucechang@via.com.tw, HaraldWelte@viatech.com, ulf.hansson@linaro.org Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org, andrianov@ispras.ru, Madhuparna Bhowmik Subject: [PATCH] drivers: mmc: host: via-sdmmc: Fix data race bug Date: Mon, 3 Aug 2020 12:58:57 +0530 Message-Id: <20200803072857.8880-1-madhuparnabhowmik10@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Madhuparna Bhowmik 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 --- 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 ef95bce50889..e4d8126cd4e5 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.17.1