Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2113360pxu; Fri, 18 Dec 2020 05:59:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJf8qOqKFsCqnrv5BH6+SMm4bK0nQmv3Mz8DPPZcuFw0+HzKgOB9bSpiAu/vN3P3LSi3IH X-Received: by 2002:aa7:d154:: with SMTP id r20mr4646531edo.258.1608299966141; Fri, 18 Dec 2020 05:59:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608299966; cv=none; d=google.com; s=arc-20160816; b=yPgueaU7mvps1UPXItqesQbM/gYLONjoLzJRSgyAp6fsR8sjLaA57tvR0Olg7oKRdL 7o5bVOsDCbrF2SsxQXGE+TdZ+uBmh/5bstO7lMXAu9MpHnN6XC++QICEUpdb6y/XedLJ aBVONXPQD50BaKIUyfsrP7NetVhmpL0Zi58hXQqqhP9lpwSn4gG79t/+P1dZEnzj/ec/ mRctHcz63brTJdu0FPxEvIKkqEGtuTwn3pEycOA2iAxuL0HrXZfPxyTnskXBwMIGkncP OZKuWgCxZo0TRaiWqpNnWpbG1COxE/wItksN+QrCgOVwT7aQoqUswnboV4Dv+DW3SsUe DJMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=GYn/KA7f+O7BovRt7bqr1CJla4mnmOL5plq1vnFMijM=; b=n1sWw7QAlfvoMs13+6h/myrcbERi4wnNU4kEMThGcwrlBwh2EgSW5z8rQyR42gzveW 4h+cm3H6+YOH/VUqV4XOYlNdAQngPMrWMRFGd5Ts+F4kRKwHlQ6jVJfE6RT0Ttjs4Rws 6/b0CVlG4CdRAbqZ36/j5d5Dt0a//p7SCAzo7f3afn+XePXHsx1H/DltUffTk9fyoO1E oMpCd5LjqSNzVnQZCgp0qQkQGZbAAOVUgDLRR/sdR2/HLx6vvPNRIFbR5ADjrRx4jF88 qFuYUsscYNuABJBcSwxPMlarrfNYdDa91UOn983zOZD46iMh7QD90/EFRuH1WDMO1hGr e2zQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zh12si4746909ejb.148.2020.12.18.05.59.03; Fri, 18 Dec 2020 05:59:26 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727098AbgLRNsG (ORCPT + 99 others); Fri, 18 Dec 2020 08:48:06 -0500 Received: from smtp13.smtpout.orange.fr ([80.12.242.135]:26015 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727074AbgLRNsF (ORCPT ); Fri, 18 Dec 2020 08:48:05 -0500 Received: from [192.168.42.210] ([93.22.133.192]) by mwinf5d71 with ME id 5pmF2400849DTe503pmFRW; Fri, 18 Dec 2020 14:46:20 +0100 X-ME-Helo: [192.168.42.210] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 18 Dec 2020 14:46:20 +0100 X-ME-IP: 93.22.133.192 Subject: Re: [PATCH] mmc: sdhci-sprd: Fix some resource leaks in the remove function To: Orson Zhai Cc: adrian.hunter@intel.com, Ulf Hansson , Baolin Wang , Lyra Zhang , linux-mmc@vger.kernel.org, Linux Kernel Mailing List , kernel-janitors@vger.kernel.org, billows.wu@unisoc.com, Wu Hongtao References: <20201217204236.163446-1-christophe.jaillet@wanadoo.fr> From: Christophe JAILLET Message-ID: <83712f89-deb7-b266-8e8a-99f0df4c6782@wanadoo.fr> Date: Fri, 18 Dec 2020 14:46:17 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 17/12/2020 à 23:55, Orson Zhai a écrit : > + cc: Billows > > Hi Christophe, > On Fri, Dec 18, 2020 at 4:50 AM Christophe JAILLET > wrote: >> >> 'sdhci_remove_host()' and 'sdhci_pltfm_free()' should be used in place of >> 'mmc_remove_host()' and 'mmc_free_host()'. >> >> This avoids some resource leaks, is more in line with the error handling >> path of the probe function, and is more consistent with other drivers. >> >> Fixes: fb8bd90f83c4 ("mmc: sdhci-sprd: Add Spreadtrum's initial host controller") >> Signed-off-by: Christophe JAILLET >> --- >> Other adjustment may be needed. >> I'm not sure at all of the 0 passed to 'sdhci_remove_host()'. Some drivers >> pass 0, some have some more complicated computation. >> --- >> drivers/mmc/host/sdhci-sprd.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c >> index f85171edabeb..5dc36efff47f 100644 >> --- a/drivers/mmc/host/sdhci-sprd.c >> +++ b/drivers/mmc/host/sdhci-sprd.c >> @@ -708,14 +708,14 @@ static int sdhci_sprd_remove(struct platform_device *pdev) >> { >> struct sdhci_host *host = platform_get_drvdata(pdev); >> struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host); >> - struct mmc_host *mmc = host->mmc; >> >> - mmc_remove_host(mmc); >> + sdhci_remove_host(host, 0); >> + >> clk_disable_unprepare(sprd_host->clk_sdio); >> clk_disable_unprepare(sprd_host->clk_enable); >> clk_disable_unprepare(sprd_host->clk_2x_enable); >> >> - mmc_free_host(mmc); >> + sdhci_pltfm_free(pdev); > > I saw a lot of drivers also use mmc_free_host(). > Do you have patches elsewhere to clean them? > As far as I can see, all drivers that use 'mmc_free_host' also use 'mmc_alloc_host'. (based on 5.10.1 and unless error) The only exception is 'sdhci-sprd.c'. So no, I don't plan any other clean-up. To spot it, I run one of my own cocci script which compare functions called in the remove function and in the error handling path of the probe. So I caught this one because 'mmc_free_host' is used in the porbe and 'sdhci_pltfm_free' in the remove function. CJ > Thanks, > -Orson > >> >> return 0; >> } >> -- >> 2.27.0 >> >