From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 26122C48BE0 for ; Fri, 11 Jun 2021 10:06:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EAD9611CD for ; Fri, 11 Jun 2021 10:06:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231482AbhFKKIf (ORCPT ); Fri, 11 Jun 2021 06:08:35 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:56976 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231140AbhFKKI3 (ORCPT ); Fri, 11 Jun 2021 06:08:29 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 2CD7A1FD3F; Fri, 11 Jun 2021 10:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623405989; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pLj8OXME0mT2ROZvbeRx1HoinugDdpFHAO6g1llgaoA=; b=iH77XjfGNlgMfoPDedBGhwwKevWKQ5/A0k5LDJ/NYrIynGojevq/03H1TncJXGA9tJbcZd NeH5rPh4NituxzpFwB8rg8X7mhbbozoVvz3U237L/4c/8ArYg7zXFEqj+O/4ON9MnSCI2G oaDOz2m+VBBcPF1Ey9ByKTHY7fPRfTI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623405989; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pLj8OXME0mT2ROZvbeRx1HoinugDdpFHAO6g1llgaoA=; b=NNsCjE5z7SmDmDqjcK15BBlKLhji0BWI27diN6tDNer3Fq+2LjOkn/oHZiJ05PaqmErDUG lnXImGv160VAY0Dg== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 26E43A3B84; Fri, 11 Jun 2021 10:06:29 +0000 (UTC) Date: Fri, 11 Jun 2021 12:06:29 +0200 Message-ID: From: Takashi Iwai To: Adrian Hunter Cc: Ulf Hansson , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mmc: sdhci: Clear unused bounce buffer at DMA mmap error path In-Reply-To: <98f90fcb-1134-f90b-db42-29f9505de046@intel.com> References: <20210611090330.13039-1-tiwai@suse.de> <98f90fcb-1134-f90b-db42-29f9505de046@intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org On Fri, 11 Jun 2021 11:56:16 +0200, Adrian Hunter wrote: > > On 11/06/21 12:03 pm, Takashi Iwai wrote: > > When DMA-mapping of the bounce buffer fails, the driver tries to fall > > back, but it leaves the allocated host->bounce_buffer although its > > size is zero. Later on, the driver checks the use of bounce buffer > > with host->bounce_buffer pointer, and it tries to use the buffer > > incorrectly, resulting in Oops. > > > > This patch clears the release the unused buffer and clears the > > bounce_buffer pointer for addressing the problem. > > > > Signed-off-by: Takashi Iwai > > One minor comment below, otherwise: > > Acked-by: Adrian Hunter > > > --- > > drivers/mmc/host/sdhci.c | 6 +++++- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > > index bf238ade1602..5f467b98ca88 100644 > > --- a/drivers/mmc/host/sdhci.c > > +++ b/drivers/mmc/host/sdhci.c > > @@ -4072,9 +4072,13 @@ static void sdhci_allocate_bounce_buffer(struct sdhci_host *host) > > bounce_size, > > DMA_BIDIRECTIONAL); > > ret = dma_mapping_error(mmc_dev(mmc), host->bounce_addr); > > - if (ret) > > + if (ret) { > > + devm_kfree(mmc->parent, host->bounce_buffer); > > Everywhere else in this function mmc_dev(mmc) is used, so maybe > use it here too instead of mmc->parent. Doh, right, I wrote a patch based on the older kernel and refreshed afterwards, but I forgot correcting this place. Will resubmit the fixed version. thanks, Takashi