From patchwork Thu Feb 27 22:05:39 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: 11410989 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 85968924 for ; Thu, 27 Feb 2020 22:06:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 65B9D246A2 for ; Thu, 27 Feb 2020 22:06:57 +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="V7tsn+wM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730069AbgB0WG5 (ORCPT ); Thu, 27 Feb 2020 17:06:57 -0500 Received: from mail26.static.mailgun.info ([104.130.122.26]:42965 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730191AbgB0WG4 (ORCPT ); Thu, 27 Feb 2020 17:06:56 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1582841216; h=References: In-Reply-To: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=L/9SUsWK5WY0wqLmzTMtMyIuQW4B95fp9pq2zAfiob4=; b=V7tsn+wMDiOJIM+E5wri4qU0aPFEnSjUpvWjANSaHULD4VMpdE3nT2ZY1NhovtNgZzg4hZ4M Gt0TAIh4wg041qBTPKPEE/zoRmR8i7Lw984vY4arl77KY0+g5ZF8KmUGupYjBnA0MD3K/JF1 bzas6ZDR2UAufWv8jC4rMrXgs7c= X-Mailgun-Sending-Ip: 104.130.122.26 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.7f0c0f1d6880-smtp-out-n01; Thu, 27 Feb 2020 22:06:40 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 1380CC447A3; Thu, 27 Feb 2020 22:06:39 +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, URIBL_BLOCKED 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 7BAE5C43383; Thu, 27 Feb 2020 22:06:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7BAE5C43383 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, "Bao D. Nguyen" , linux-arm-msm@vger.kernel.org Subject: [ 1/4] mmc: core: Add check for NULL pointer access Date: Thu, 27 Feb 2020 14:05:39 -0800 Message-Id: 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 If the SD card is removed, the mmc_card pointer can be set to NULL by the mmc_sd_remove() function. Check mmc_card pointer to avoid NULL pointer access. Signed-off-by: Bao D. Nguyen Signed-off-by: Asutosh Das --- drivers/mmc/core/bus.c | 5 +++++ drivers/mmc/core/core.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index 74de3f2..4558f51 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c @@ -131,6 +131,11 @@ static void mmc_bus_shutdown(struct device *dev) struct mmc_host *host = card->host; int ret; + if (!card) { + dev_dbg(dev, "%s: %s: card is NULL\n", dev_name(dev), __func__); + return; + } + if (dev->driver && drv->shutdown) drv->shutdown(card); diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 6b38c19..94441a0 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -666,6 +666,9 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card) { unsigned int mult; + if (!card) + return; + /* * SDIO cards only define an upper 1 s limit on access. */ From patchwork Thu Feb 27 22:05:40 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: 11410975 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 254CA924 for ; Thu, 27 Feb 2020 22:06:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03848246A2 for ; Thu, 27 Feb 2020 22:06:49 +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="OOJNyURN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729982AbgB0WGs (ORCPT ); Thu, 27 Feb 2020 17:06:48 -0500 Received: from mail26.static.mailgun.info ([104.130.122.26]:25259 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730149AbgB0WGs (ORCPT ); Thu, 27 Feb 2020 17:06:48 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1582841208; h=References: In-Reply-To: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=WZi02PQIcWxOofn2zJpdxNdKBMBRPTUWVVvGceBRIeg=; b=OOJNyURNEekUKU1XbYTPQq5T8vZszzBQL7Ho2U9w0/LhJXYsVYD4EG/hmDy6oGfNiNmcKvFy 6wat0SorQlx8MMvKxduQJKjiG08ssH1BRkmhyCACf7KNSzRq8F7b8S+R9mgHBMRmmffSM8MC vOhFfLQgo4aTo90sAtnQzkLVNxA= X-Mailgun-Sending-Ip: 104.130.122.26 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 5e583d6f.7fde0a4ba538-smtp-out-n02; Thu, 27 Feb 2020 22:06:39 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id ADCEFC4479D; Thu, 27 Feb 2020 22:06:38 +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, URIBL_BLOCKED autolearn=ham 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 067BBC433A2; Thu, 27 Feb 2020 22:06:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 067BBC433A2 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, Subhash Jadavani , linux-arm-msm@vger.kernel.org, Murali Palnati , "Bao D. Nguyen" Subject: [ 2/4] mmc: core: Attribute the IO wait time properly in mmc_wait_for_req_done() Date: Thu, 27 Feb 2020 14:05:40 -0800 Message-Id: <00979679b191fd9704664d06b0642c9eb3b4b00c.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: Subhash Jadavani In mmc_wait_for_req_done() function, change the call wait_for_completion() to wait_for_compltion_io(). This change makes the kernel account for wait time as I/O wait and through another configuration, this io wait is treated as busy which makes the acpu clock to scale up. Signed-off-by: Murali Palnati Signed-off-by: Subhash Jadavani Signed-off-by: Bao D. Nguyen Signed-off-by: Asutosh Das --- drivers/mmc/core/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 94441a0..97a384a 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -399,7 +399,7 @@ void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq) struct mmc_command *cmd; while (1) { - wait_for_completion(&mrq->completion); + wait_for_completion_io(&mrq->completion); cmd = mrq->cmd; 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: 11410969 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 3C431138D 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 1BB9024677 for ; Thu, 27 Feb 2020 22:06:45 +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) 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, URIBL_BLOCKED autolearn=ham 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 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; } /* From patchwork Thu Feb 27 22:05:42 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: 11410981 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 8FCD4924 for ; Thu, 27 Feb 2020 22:06:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 70308246A2 for ; Thu, 27 Feb 2020 22:06:54 +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="S3jj8Bn1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729776AbgB0WGy (ORCPT ); Thu, 27 Feb 2020 17:06:54 -0500 Received: from mail26.static.mailgun.info ([104.130.122.26]:25259 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730187AbgB0WGx (ORCPT ); Thu, 27 Feb 2020 17:06:53 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1582841213; h=References: In-Reply-To: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=KA5SegCo5AW0cExJCz9BWH9qh1K5CDu6sI3vMXYPwJc=; b=S3jj8Bn127oG/+b1JpXKOds8/FS8ZwYdRIasUENwuZL5nbgWk1sIn1W8+PVo44bOAXnhYemr ZEp3uaGkh1Jht5KZU5HbnL0Z4jJ8aSJSgfNVdOawrzOHnLMIpKHm0MdPHfx7bL1KBg1Fq6f8 NlU38gBoBQF+LvuAHpP8HuXCy2c= X-Mailgun-Sending-Ip: 104.130.122.26 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 5e583d71.7fb467084030-smtp-out-n03; Thu, 27 Feb 2020 22:06:41 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 16488C447A0; Thu, 27 Feb 2020 22:06:40 +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, URIBL_BLOCKED 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 2ED8FC43383; Thu, 27 Feb 2020 22:06:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 2ED8FC43383 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, Sahitya Tummala , linux-arm-msm@vger.kernel.org, "Bao D. Nguyen" Subject: [ 4/4] mmc: core: update host->card after getting RCA for SD card Date: Thu, 27 Feb 2020 14:05:42 -0800 Message-Id: <630eb41f01456cd862495166b9cef2b36ae2861e.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: Sahitya Tummala Make the host->card available before tuning is invoked for SD card. In the sdhci_msm_execute_tuning(), we will send CMD13 only if host->card is present because it needs the card->rca as its argument to be sent. For emmc, host->card is already updated immediately after the mmc_alloc_card(). In the similar way, this change is for SD card. Without this change, tuning functionality will not be able to send CMD13 to make sure the card is ready for next data command. If the last tuning command failed and we did not send CMD13 to ensure card is in transfer state, the next read/write command will fail. Signed-off-by: Sahitya Tummala Signed-off-by: Bao D. Nguyen Signed-off-by: Asutosh Das --- drivers/mmc/core/sd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 76c7add..f0872e3 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -989,6 +989,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, err = mmc_send_relative_addr(host, &card->rca); if (err) goto free_card; + host->card = card; } if (!oldcard) { @@ -1100,12 +1101,13 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, goto free_card; } done: - host->card = card; return 0; free_card: - if (!oldcard) + if (!oldcard) { + host->card = NULL; mmc_remove_card(card); + } return err; }