Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3243044pxu; Sat, 19 Dec 2020 18:06:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJzHtUYQrTntAz1OToqHCvvia/AlcAUYMVfN5Qby7uU8JZ1owRVlk5E0lgRJSoeJcNQBGRg8 X-Received: by 2002:a17:906:2f8b:: with SMTP id w11mr5094776eji.246.1608430012502; Sat, 19 Dec 2020 18:06:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608430012; cv=none; d=google.com; s=arc-20160816; b=bgL6dVGbFlDYh+K54dPFFzIOjaa6/vL/0SpPBLNd9w/+vNT5GOMOVPJ6J7bt6pGBNG enIimLZ5bqxWzFBOliH6DhjnP40+A1Q4Lw1rxwZd5FNjFA6654cgT9uQJNHsujlL9fwT KEAw+k2SnZX6oVl3T4bcvO9mcAQiimxUsKD7v+X1aBkezZ5ieieQPP9CPdUVUPw+ja9O NRWeP2yXq7910bHYPx09I0GPyPN5ZehdvUBBxyIsrpBoeWQYSOHCpvloxNPFPKzUU2nq rJ4HXbwn15j16/0zRqH32zz3xJl5J0X798PasQ89X2nmQhpLtg1LxhRzNtgucQJLvJZV m7fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=8vAJhtcnlmR0zuqlLalCyJpLf4qWM/qYJIE1uR2kv+o=; b=zCqmEhdb8x1Dw/DTVkH8LouqJm1HtEChVkrMukSBKNVfFpRcTHGRkJ8CRuH6Y6Hvfs ekSx2km0r1Ny3iM3uPY+Ges7dHOxPIEDEN+2ZY2PxzF5e5a9o8B+Z8k1UYCmUScwHJJq VAwVOHog0i9YJevOVhnUYKF+xtkD0VaJxuYu0CEEhUDGdW5xbUnhtW/iSogBDfbPaaeJ OkFOst8q12KcfZk86tKpIW7+BiZ0QO3iSobyUhsUmGx7J0xIV4T+Z4jLISy+zpC/3XHz Jpb98F1Jz1BzrTRklD6oDdNS2HkjbVOqwp+sVti69CuyoohprRcFHSxiW15a2ssfE0uc osQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lgJsdSHk; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e23si8857700edc.252.2020.12.19.18.06.30; Sat, 19 Dec 2020 18:06:52 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lgJsdSHk; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726944AbgLTCGD (ORCPT + 99 others); Sat, 19 Dec 2020 21:06:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726732AbgLTCGD (ORCPT ); Sat, 19 Dec 2020 21:06:03 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97CCEC0613CF; Sat, 19 Dec 2020 18:05:21 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id j13so4079099pjz.3; Sat, 19 Dec 2020 18:05:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=8vAJhtcnlmR0zuqlLalCyJpLf4qWM/qYJIE1uR2kv+o=; b=lgJsdSHkqmPd+lGQpOuxo/BQACNoudnJUUT8uihKs5KlWVeAkWzu1SPoqXEdcOkRcp M8/jeh7IPRNlFOz47a/5vyyTUSBKQuVv1BVkGX8OU+e0x4nS4RCkCFp356zXIbquOyJ1 kUG/FgxcvTm/rWzd5bohBc+dOP5JMqnj6Jziq3FWt95B3QJBR7n9QhTvQqrjSUiaRcyJ UGmPmIxao0b7VAsXrxMwoi0B//tKCRENHto02WttC+HDcn4j8ZikECh0eU/Ies6VnWfG fBcukb4h/tmnH7xVfTAXMb76pw7a1AH+rq914z5yGu7w8M1BtN5QBxsiSU5/LjPoOGhc smpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=8vAJhtcnlmR0zuqlLalCyJpLf4qWM/qYJIE1uR2kv+o=; b=S3ZsPVM6V8B/8d4bs9J84XoUUI2F3J3Li5G5eHXqaSuos3vycgtSmDFVW5OmxxBLCo 337n0+zpMC67vn8pATlrGcsfDwCBCNl1JrugjBrWYxMxq5DOxqSbGIcXZp8gAABl2yQP 9FCdB8vF+4+pKipSEgVHQfWzFvRQVmEogPN3TwojqZnOCIkQMp9VnLWBLAT5ga+ri9oH 2Ig9cdGI4kEHLRLExHnoYUXdzOqb+mHeDcuIG6z1a76koyBZAnr1HcdlbnnC9EuCZ4oM cuue3PP3YaVM/Yjh90PbVQcIWID3Hz+QvDGfqnR6yB0frz2tZrZn6b06m6xdE1ugKMdD UwqA== X-Gm-Message-State: AOAM532C61A5nHd1p6QRSShzvMPPzx+aLt9faijPtCqxeYVrSyG6mLfW XmKjYZ3de0xfsWc4RveU0PqBvnT08ymFUaCMSgs= X-Received: by 2002:a17:902:7d84:b029:db:feae:425e with SMTP id a4-20020a1709027d84b02900dbfeae425emr10900360plm.43.1608429921087; Sat, 19 Dec 2020 18:05:21 -0800 (PST) MIME-Version: 1.0 References: <20201217204236.163446-1-christophe.jaillet@wanadoo.fr> <83712f89-deb7-b266-8e8a-99f0df4c6782@wanadoo.fr> In-Reply-To: <83712f89-deb7-b266-8e8a-99f0df4c6782@wanadoo.fr> From: Orson Zhai Date: Sun, 20 Dec 2020 10:05:09 +0800 Message-ID: Subject: Re: [PATCH] mmc: sdhci-sprd: Fix some resource leaks in the remove function To: Christophe JAILLET 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 18, 2020 at 9:46 PM Christophe JAILLET wrote: > > Le 17/12/2020 =C3=A0 23:55, Orson Zhai a =C3=A9crit : > > + 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 handli= ng > >> path of the probe function, and is more consistent with other drivers. > >> > >> Fixes: fb8bd90f83c4 ("mmc: sdhci-sprd: Add Spreadtrum's initial host c= ontroller") > >> 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 dri= vers > >> 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-sp= rd.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_dev= ice *pdev) > >> { > >> struct sdhci_host *host =3D platform_get_drvdata(pdev); > >> struct sdhci_sprd_host *sprd_host =3D TO_SPRD_HOST(host); > >> - struct mmc_host *mmc =3D 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. Thanks for the clarification. Acked-by: Orson Zhai > > > CJ > > > Thanks, > > -Orson > > > >> > >> return 0; > >> } > >> -- > >> 2.27.0 > >> > > >