Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp5482497rwb; Wed, 9 Aug 2023 05:05:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjOz+2JUc9PDrgyFm+usyOOFYQZZN2Iy0G4nO3lZm9IqBHIpHUgqgWUd81npM3bQb/XUUG X-Received: by 2002:a17:903:120c:b0:1b8:b3f0:3d57 with SMTP id l12-20020a170903120c00b001b8b3f03d57mr2540982plh.31.1691582729420; Wed, 09 Aug 2023 05:05:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691582729; cv=none; d=google.com; s=arc-20160816; b=q6Ny5IfV2HDY0L+XJ3T4SDXfEdRRW/er7ZTqxSvp1UbqWriqecAMhFyC2gMklV/3IJ n6iv5HdjGBiUaBXTXRK55CLD7Qv81MNzAY3JnZGvYKVObZHZiVYnu4drycZN0tUq6ccm kS2Pp7Oqmp11YhaHq/eO2h/OJF7Gz1HBgZQytur1Ji7rzcGxF23w28bHfa0Iwx8nmI7w hghqSMy8dgx5XwnZNH9Unp35kKeC41tPUvmCInGXmCv+bWrrzVxUyQmF5hQLTsRcrAZZ WY4NC1FprcNvAkZcmZwpKXB3yZ3HL2NThuYAHwJgy9MVDSvumiuw4Y5guo9Ub7BgCHhU TeSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/Qd5Q30zi0GR+tG5MZxvetxiAiJ73IWmx5JKTPRK8+M=; fh=ZvI+FVnJCzGEx7AT1adD7qOg+sixLQ7mf0IPHhEV/yg=; b=Wzj9FJ6uM+0Vp11WxMVKE5oy4aS5hEMcactXVk2KsuS4zFW2Efnx1QYDH9ssGgLJmd 7EQ0hBeXcxChkgcybG/OwsiamdmK4sxJUXhQOGvRgd9RCR8Qdtu7GmMODszn9YyDrJkw VMyCD8gKYfdoGxKnxeYs4xF6ymfTlZSiivL1vj3ZzSSj6SE2srqzKgP21u8P/YCUAHr4 m7kFlJV3rzLaMJuy4n/yk1ennMq8nJxExsb3NLUsmG70mKKcK39XzxR0VTxbssPTBMH0 UqgInp5DmBOdBEP7qPFTC6W320B1MFdEjKoPXfXhAFuwsN2CNUA9VxI3WaL34/G0se5e 8gCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PsPJSySr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jx15-20020a170903138f00b001b8b37f0ab0si8729693plb.280.2023.08.09.05.05.16; Wed, 09 Aug 2023 05:05:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PsPJSySr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233469AbjHILST (ORCPT + 99 others); Wed, 9 Aug 2023 07:18:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233459AbjHILSS (ORCPT ); Wed, 9 Aug 2023 07:18:18 -0400 Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 273F4172A for ; Wed, 9 Aug 2023 04:18:17 -0700 (PDT) Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-586b78aa26eso52856067b3.1 for ; Wed, 09 Aug 2023 04:18:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691579896; x=1692184696; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=/Qd5Q30zi0GR+tG5MZxvetxiAiJ73IWmx5JKTPRK8+M=; b=PsPJSySrL4AnBphkJ34Jv0ktjJiWLoGrA/sq7XyP/aocCNnNVVapqD/jVC/jT/SHv6 W3+QIbDL0CQjvcuhZrpDMe6qBZ6eTm1hRW2HEf8ddNI8dO02GYGBjaBNI9zh+cjOIKlU gluh3SYeSfB3YE5OEhw5vpVXhPaavrWUpNTPUbfSFKTEXWF7p2U/Jt1Zt9k7pKwPrAcv pewodTa76tgUEZ+dAMEtkF55dIcZrnVcR2rm3f3vfgtORR+FZ1X6stjY3+wEvdogxRfH MZpnYDQbp+5U3n8oWDYzUnpfFIe2H9zkPE8gC8z9qsIHLPGOuOetOVgOOwvuQcNK0W7B wE0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691579896; x=1692184696; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/Qd5Q30zi0GR+tG5MZxvetxiAiJ73IWmx5JKTPRK8+M=; b=F44EVjicthNUxkoZlRsIiX9A4mpuR5r77zjtAoX9PEExakYGcV7J/t/i44XZvq+f6D CTysRBcODVMXnOc7Gz7RSVuRUmuDnl3h6pImEvOTADmghMJtSGPI+m23vvHC/qgy09Cu si68dkRzZ6rvqHjSC32fDUlMuUvyheEfBI/dViBpVHhp3NIGoNkIbooQtdPcm4SoEGPX q1D275bnpCa4JWcG+fzfRrCvM+dWgnOH+3/Tv9QiAKZpabiG5a9iPXjJI8Boebud4Dhf dXrVbH29uHkljeAiwsKtVANVKypSSMhRt4F4Y27DSb5sxVcqpSVvjpYLUpNRv6/RGD22 KQGg== X-Gm-Message-State: AOJu0YyTQ7ADIrPX2RW+587zgj0CNEs2N4x3U/ELIZOQUIwgbtteE1jg ezf8G2Wf8MV15Z/Kg59/xZbO8CRlCqjV2ZVL6l34vg== X-Received: by 2002:a81:c311:0:b0:589:8b55:f7f4 with SMTP id r17-20020a81c311000000b005898b55f7f4mr2160229ywk.33.1691579896376; Wed, 09 Aug 2023 04:18:16 -0700 (PDT) MIME-Version: 1.0 References: <20230809071812.547229-1-harshit.m.mogalapalli@oracle.com> In-Reply-To: From: Ulf Hansson Date: Wed, 9 Aug 2023 13:17:40 +0200 Message-ID: Subject: Re: [PATCH next v2 1/2] mmc: sunplus: Fix error handling in spmmc_drv_probe() To: Harshit Mogalapalli Cc: tonyhuang.sunplus@gmail.com, lhjeff911@gmail.com, dan.carpenter@linaro.org, arnd@arndb.de, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, error27@gmail.com, kernel-janitors@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 9 Aug 2023 at 13:08, Ulf Hansson wrote: > > On Wed, 9 Aug 2023 at 09:18, Harshit Mogalapalli > wrote: > > > > When mmc allocation succeeds, the error paths are not freeing mmc. > > > > Fix the above issue by changing mmc_alloc_host() to devm_mmc_alloc_host() > > to simplify the error handling. Remove label 'probe_free_host' as devm_* > > api takes care of freeing, also remove mmc_free_host() from remove > > function as devm_* takes care of freeing. > > > > Fixes: 4e268fed8b18 ("mmc: Add mmc driver for Sunplus SP7021") > > Reported-by: Dan Carpenter > > Closes: https://lore.kernel.org/all/a3829ed3-d827-4b9d-827e-9cc24a3ec3bc@moroto.mountain/ > > Signed-off-by: Harshit Mogalapalli > > This doesn't apply on my next branch, please rebase it. > > Moreover, it looks like you should replace a few more "goto > probe_free_host;" with "return ret;". Please have a closer look. Oh, my bad, please ignore the above! I had another fix for the sunplus driver queued on my next branch. I have moved that patch to fixes and applied your patch on top, thanks! Kind regards Uffe > > --- > > This is based on static analysis with smatch, only compile tested. > > > > v1->v2: Simplify code by using devm_mmc_alloc_host() instead of > > mmc_alloc_host() (Ulf Hansson's suggestion) > > --- > > drivers/mmc/host/sunplus-mmc.c | 14 +++----------- > > 1 file changed, 3 insertions(+), 11 deletions(-) > > > > diff --git a/drivers/mmc/host/sunplus-mmc.c b/drivers/mmc/host/sunplus-mmc.c > > index a55a87f64d2a..2bdebeb1f8e4 100644 > > --- a/drivers/mmc/host/sunplus-mmc.c > > +++ b/drivers/mmc/host/sunplus-mmc.c > > @@ -863,11 +863,9 @@ static int spmmc_drv_probe(struct platform_device *pdev) > > struct spmmc_host *host; > > int ret = 0; > > > > - mmc = mmc_alloc_host(sizeof(*host), &pdev->dev); > > - if (!mmc) { > > - ret = -ENOMEM; > > - goto probe_free_host; > > - } > > + mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(struct spmmc_host)); > > + if (!mmc) > > + return -ENOMEM; > > > > host = mmc_priv(mmc); > > host->mmc = mmc; > > @@ -938,11 +936,6 @@ static int spmmc_drv_probe(struct platform_device *pdev) > > > > clk_disable: > > clk_disable_unprepare(host->clk); > > - > > -probe_free_host: > > - if (mmc) > > - mmc_free_host(mmc); > > - > > return ret; > > } > > > > @@ -956,7 +949,6 @@ static int spmmc_drv_remove(struct platform_device *dev) > > pm_runtime_put_noidle(&dev->dev); > > pm_runtime_disable(&dev->dev); > > platform_set_drvdata(dev, NULL); > > - mmc_free_host(host->mmc); > > > > return 0; > > } > > -- > > 2.39.3 > >