From patchwork Thu Feb 27 22:05:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bao D. Nguyen" X-Patchwork-Id: 190200 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=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 102D9C3F2C0 for ; Thu, 27 Feb 2020 22:06:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D5EF5246A2 for ; Thu, 27 Feb 2020 22:06:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="leHuIBSB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729932AbgB0WGo (ORCPT ); Thu, 27 Feb 2020 17:06:44 -0500 Received: from mail27.static.mailgun.info ([104.130.122.27]:33694 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729776AbgB0WGo (ORCPT ); Thu, 27 Feb 2020 17:06:44 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1582841203; h=References: In-Reply-To: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=mAYzulBLrtv9dI1ahVgr6ecOQiw6N8U8f+/YZ+XrAqw=; b=leHuIBSBn2al6nEDG3RiD9ovb1MZw7NUG4Kx0djWTyDzXMF4iDUz+T1qqiXm2gS/YK/CIX5L DChT/NT0QLiQ7UFml9pLom7mm0izJtfgJ+PH7pif823tH3s6KLcaClthUp4DMhet8hpEz36j fimhkahicXt/Sxva2lE5mYzgSWs= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyI1MzIzYiIsICJsaW51eC1hcm0tbXNtQHZnZXIua2VybmVsLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e583d70.7f823c89dd88-smtp-out-n02; Thu, 27 Feb 2020 22:06:40 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 432EFC447A2; Thu, 27 Feb 2020 22:06:39 +0000 (UTC) Received: from pacamara-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: nguyenb) by smtp.codeaurora.org (Postfix) with ESMTPSA id 996BAC4479F; Thu, 27 Feb 2020 22:06:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 996BAC4479F Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=nguyenb@codeaurora.org From: "Bao D. Nguyen" To: ulf.hansson@linaro.org, robh+dt@kernel.org, linux-scsi@vger.kernel.org Cc: linux-mmc@vger.kernel.org, asutoshd@codeaurora.org, cang@codeaurora.org, Ritesh Harjani , linux-arm-msm@vger.kernel.org, "Bao D. Nguyen" Subject: [ 3/4] mmc: core: Make host->card as NULL when card is removed Date: Thu, 27 Feb 2020 14:05:41 -0800 Message-Id: <3addbea5a12e783a802d57a901785e5c9f7f858d.1582839544.git.nguyenb@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Ritesh Harjani Make host->card as NULL when card is removed otherwise we do see some kernel crashes in async contexts, where host->card is referred (as dangling pointer). Signed-off-by: Ritesh Harjani Signed-off-by: Bao D. Nguyen Signed-off-by: Asutosh Das --- drivers/mmc/core/bus.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index 4558f51..4677603 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c @@ -252,12 +252,15 @@ void mmc_unregister_driver(struct mmc_driver *drv) static void mmc_release_card(struct device *dev) { struct mmc_card *card = mmc_dev_to_card(dev); + struct mmc_host *host = card->host; sdio_free_common_cis(card); kfree(card->info); kfree(card); + if (host) + host->card = NULL; } /*