Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp5477569rwb; Wed, 9 Aug 2023 05:02:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGfqAk1NkvpmNQQ8a90YwngXaNqy8GkIUUCyhStvGkIusfRaSG6wR2/5zAZYtjq78hjnCox X-Received: by 2002:a17:902:d4c1:b0:1b8:6cac:ffe8 with SMTP id o1-20020a170902d4c100b001b86cacffe8mr2896951plg.51.1691582544017; Wed, 09 Aug 2023 05:02:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691582544; cv=none; d=google.com; s=arc-20160816; b=rUtDZdB1Gfgb/v+ikmWOElg/1z6yaqs5WeKMpAWWwhSgEFjMaVIMXAs0IL9zuJv7Lw Pd/XhpEL8cjhqpadOyMc63EaUHlnmkji4FeIUaCDgcocqlA1CzDKkqU60nB+iLMwsjc0 UmiU/9oIVJz+pmwVrGg51aSmgkYvi8CPxgcjTuLPbl9OjheBqSVNgpVY1C8PYqzC/IMD ARKqn0np6WfpTy4ipftN4In//f5Jz5B+0NsYtSYHtbjVKTG4mnMSeGsI+rxfCORTCdpM ngO/nfm8SsOHecKlOd1cfbAsijLLwt1fzvR6Zagi58ZhnAB0XzSOCcfAltXuC2WbdB6g 68Ug== 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=lFOUEDGDfnO6FgesixYMbqfbNJGm4+REhXT9PFqBZFw=; fh=ZvI+FVnJCzGEx7AT1adD7qOg+sixLQ7mf0IPHhEV/yg=; b=Z4oNyxJ/LsD9oYPQKy/AA2FrX1VGvpSO7Qx9GXPJgZi4UeeEQ1+cHes3zKxYU4vx4B 4N8A/ZuYnkFqVbnRsum+Z23ugCurl1zh6bReh2Hp4E+WC/RbHyY/ZJ0E5dOlAj0AJg2E G+dDj/eyMxumSqG40xYguDrlngny88ZCoRS0yRwPeKpI0BNhqaeBmuRfXmPKcFr/mmWK zqLKvhS+PdrjN9NCrBWZYKRyBrEvSzOUuDigEOj5JHa4cDD97hOjpnNLu6q8XfnM8EhQ TKhMj9FqcyMZViEGd0NeyrhpJghmIpHABV2M5wWKRWlItF3CwQ+T7L1krayCHSDHLiJU NqaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sN3Bjk9M; 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 s10-20020a17090302ca00b001bb2d95f2a7si6341439plk.267.2023.08.09.05.02.09; Wed, 09 Aug 2023 05:02:23 -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=sN3Bjk9M; 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 S233184AbjHILIj (ORCPT + 99 others); Wed, 9 Aug 2023 07:08:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233186AbjHILIh (ORCPT ); Wed, 9 Aug 2023 07:08:37 -0400 Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA77E1BF7 for ; Wed, 9 Aug 2023 04:08:36 -0700 (PDT) Received: by mail-yb1-xb29.google.com with SMTP id 3f1490d57ef6-d5d64d2961aso1019775276.3 for ; Wed, 09 Aug 2023 04:08:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691579316; x=1692184116; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=lFOUEDGDfnO6FgesixYMbqfbNJGm4+REhXT9PFqBZFw=; b=sN3Bjk9MMzThJz+d2fP+SCRGKYstwupZu4+xtUswcVVDr1aGRsPt2b4JDKwZ6bdQD1 zj1vKtGoI2f0QY8xhbIDtS/S1YYLimgbbj6UpdTBRDOVxP0NhmfcUJw3KCB+A8oCxBgc DELXJa4x+NWhB5TyqzPYxVDcNBMwyctYsbRVjz00jvo2GYMDkIeRQ7YHrEfEZobpZqC9 1MsIjtQ4CXIpUvPDSnmLuvSPED3K7OcRv6Ax9RoJwxmcg6tit1p9VKKdQuIsMWU5WWj5 UKg+m67k66XJ1z8E2GKliTzhPBc7rLztCFLKMvPFY/FazBeU3YT7t3upj7UVvecBNGQv th1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691579316; x=1692184116; 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=lFOUEDGDfnO6FgesixYMbqfbNJGm4+REhXT9PFqBZFw=; b=DLKyBL29xhd2F8X6kmMVnKLYiR+huFHT2MVrcNrjxFE2N0Tsjj3ggj81LKJzk+28Uo PYixlfvHK4ddp/OcxBKD/jNU13jZMe1jjLZKrYXbbRLoQVlBXXVOc/Vyk2rnENADylRn 7QmyCj9lKTHebk72dQcd0L30Hvr3ui7lvIX08i8nr/DjbZmH7YAZtoSPedR/ALN/M/tq 8mO9O0+IPpgzAMNQhoE9tk1IY39L1u7Zns300yGLSF5gHjlNwfCvSZUBDQLZdT5uwShk pF8QDf55id8oU1KAHjU/54Y5dcIwyCjDkr3yfumH4edsUsq2QfNM6Q8kzhlcGoa2XbLQ H68A== X-Gm-Message-State: AOJu0YyN3wkc0DGrSxsm7DJ+w15efgfvZahpsntTf4EcY1q26gl+xWbQ nSzJRw2bWgzImJ3iXhk9l7DuNdDAsWS8vcUATIaryQ== X-Received: by 2002:a25:d383:0:b0:d37:d0f4:f0b2 with SMTP id e125-20020a25d383000000b00d37d0f4f0b2mr2599136ybf.19.1691579316090; Wed, 09 Aug 2023 04:08:36 -0700 (PDT) MIME-Version: 1.0 References: <20230809071812.547229-1-harshit.m.mogalapalli@oracle.com> In-Reply-To: <20230809071812.547229-1-harshit.m.mogalapalli@oracle.com> From: Ulf Hansson Date: Wed, 9 Aug 2023 13:08:00 +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_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 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. 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 >