From patchwork Sat Dec 10 18:36:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 32083 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1449949wrr; Sat, 10 Dec 2022 10:38:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf7ZKqCqM2P2c57AkO9k49gfTSm4SCZZFYSWCNTyd6bXjk+t+3A5vi/D/ly3y17VcQuO8KSR X-Received: by 2002:a17:906:b810:b0:7c1:5467:39b1 with SMTP id dv16-20020a170906b81000b007c1546739b1mr1820852ejb.72.1670697507968; Sat, 10 Dec 2022 10:38:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670697507; cv=none; d=google.com; s=arc-20160816; b=QLnVuT7UAa+OKeNw7gF1S1ut908Y8mIi7bwXjxMXVdZv38PiSlpxfwtiN+wfDvhYRY AjtXqsSuLURlPhksOurrOEOfi4qEPDTsmmWfiKLASMXYZM+dj2YX+og3PkF2XaG7VHSs 16fpoEJENJ8cMqwEucUJOcMp7CtJNHCZBk7eyPuc4PFMjKTlcsnQFi7RE7iG5QSWVZJW DM9qtHLbkE0/veccLpvqn3EeMWL+WH9gxljPPyh1mB982WbgatyK17Tf4+iPG34x5tcZ uk9Sz6gH/JkuoWWoGmZS+Oq3aO8x4H8TF/dzawFltBFYLgdBMF+lKqKDHEh1V6a1isbl MKiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=19pxnp+2cXMQQvka+JPJKBmniYU7WKohLMhTqwMajGk=; b=QG62ZVh62ipkoP4mOXkJXUIKbWh5htLIoklMDLxp6pgfSq7WucYl5ZjdR8KPcKZiZ+ wqqGq7jm1mt/VhPhqv+J+wwbTtbEYHBMmgmSRSX/CSaHZ3VCI38FXhHWNVoOVyUeRBA5 NzOKicRL61htKIlb8aIeLOR0NY8D4+8u5oQmes3JstARriydkaItzDH74gW2dtNspzsM AftTiMP8dHMRUVdL9usCZ9yxDuhzq7ftyXmz3a9C5RIgbSwLq0BGZsaEXypGT87zIBny LxJvnKy6i4mMS+Pv6VZRII7z5FSisj+l8xc1P+jSLBx2opMhL+LoR4rex1SJgTa+vpiN xrow== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lf3-20020a170907174300b007316ac034acsi2197903ejc.834.2022.12.10.10.38.05; Sat, 10 Dec 2022 10:38:27 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229750AbiLJSgv (ORCPT + 99 others); Sat, 10 Dec 2022 13:36:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229749AbiLJSgt (ORCPT ); Sat, 10 Dec 2022 13:36:49 -0500 Received: from smtp.smtpout.orange.fr (smtp-28.smtpout.orange.fr [80.12.242.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 213C913DE1 for ; Sat, 10 Dec 2022 10:36:49 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id 44iJpNwaA1SdM44iNpAGvA; Sat, 10 Dec 2022 19:36:47 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 10 Dec 2022 19:36:47 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: Tony Huang , Li-hao Kuo , Ulf Hansson , Arnd Bergmann Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-mmc@vger.kernel.org Subject: [PATCH 2/3] mmc: sunlpus: Fix a memory leak in case of error in spmmc_drv_probe() Date: Sat, 10 Dec 2022 19:36:38 +0100 Message-Id: <9c52251e1ba837ca204e253627679f1e42ebe9fa.1670697358.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <7c686fecb11b4ec1f55cd7075dc7cfcdd9b445ba.1670697358.git.christophe.jaillet@wanadoo.fr> References: <7c686fecb11b4ec1f55cd7075dc7cfcdd9b445ba.1670697358.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751853309993796881?= X-GMAIL-MSGID: =?utf-8?q?1751853309993796881?= If an error occurs after a successful mmc_alloc_host() call in the probe, the error handling path should be executed in order to call mmc_free_host(). Fixes: 4e268fed8b18 ("mmc: Add mmc driver for Sunplus SP7021") Signed-off-by: Christophe JAILLET --- drivers/mmc/host/sunplus-mmc.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/sunplus-mmc.c b/drivers/mmc/host/sunplus-mmc.c index 3e8856a82188..ed789a9bdd23 100644 --- a/drivers/mmc/host/sunplus-mmc.c +++ b/drivers/mmc/host/sunplus-mmc.c @@ -875,26 +875,34 @@ static int spmmc_drv_probe(struct platform_device *pdev) host->dma_int_threshold = 1024; host->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); - if (IS_ERR(host->base)) - return PTR_ERR(host->base); + if (IS_ERR(host->base)) { + ret = PTR_ERR(host->base); + goto probe_free_host; + } host->clk = devm_clk_get_enabled(&pdev->dev, NULL); - if (IS_ERR(host->clk)) - return dev_err_probe(&pdev->dev, PTR_ERR(host->clk), "clk get fail\n"); + if (IS_ERR(host->clk)) { + ret = dev_err_probe(&pdev->dev, PTR_ERR(host->clk), "clk get fail\n"); + goto probe_free_host; + } host->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); - if (IS_ERR(host->rstc)) - return dev_err_probe(&pdev->dev, PTR_ERR(host->rstc), "rst get fail\n"); + if (IS_ERR(host->rstc)) { + ret = dev_err_probe(&pdev->dev, PTR_ERR(host->rstc), "rst get fail\n"); + goto probe_free_host; + } host->irq = platform_get_irq(pdev, 0); - if (host->irq <= 0) - return host->irq; + if (host->irq <= 0) { + ret = host->irq; + goto probe_free_host; + } ret = devm_request_threaded_irq(&pdev->dev, host->irq, spmmc_irq, spmmc_func_finish_req, IRQF_SHARED, NULL, host); if (ret) - return ret; + goto probe_free_host; ret = mmc_of_parse(mmc); if (ret)