From patchwork Fri Mar 6 04:58:17 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: 11423109 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D3FF9139A for ; Fri, 6 Mar 2020 04:59:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B1FFB2084E for ; Fri, 6 Mar 2020 04:59:28 +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="YRzenKL2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726413AbgCFE72 (ORCPT ); Thu, 5 Mar 2020 23:59:28 -0500 Received: from mail27.static.mailgun.info ([104.130.122.27]:55876 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726440AbgCFE72 (ORCPT ); Thu, 5 Mar 2020 23:59:28 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1583470767; h=References: In-Reply-To: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=5MWQLtho3ToFXSVprC0VQBc7lkh4LWocTd4tRw1QnuM=; b=YRzenKL2IkBAHDA8M8rl8HPjiL4QKTZpPhx+JnfygqV6XVuYNeuBtrK3l5GfA2xfudE6vCRn yvpiidNelmyUBKL7487F1kSUFJ+UU+d60zs2BeNZtg1A9cnq2/sR+W9IU4c3U/AbdxlZdf38 Aq0Cj827iM2CjRKW4i5F7thys8g= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyJiYTcxMiIsICJsaW51eC1tbWNAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd 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 5e61d8a9.7f45f5bef068-smtp-out-n02; Fri, 06 Mar 2020 04:59:21 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id B30ADC433A2; Fri, 6 Mar 2020 04:59:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 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 EA478C43383; Fri, 6 Mar 2020 04:59:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org EA478C43383 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: [PATCH v2 3/4] mmc: core: Make host->card as NULL when card is removed Date: Thu, 5 Mar 2020 20:58:17 -0800 Message-Id: <17f39df2f08f6d40b829d115255ddb2d2ef4bc2a.1583470026.git.nguyenb@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@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 74de3f2..e83821c 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c @@ -247,12 +247,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; } /*