Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2658343pxa; Mon, 17 Aug 2020 15:45:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7C3OpDt+azrp4Wp+wUcjgno8+/cTG7pMans09mAHrDDsVRCrDCWhpe6oSNQv4fPiN/hMn X-Received: by 2002:a17:906:3493:: with SMTP id g19mr18209758ejb.253.1597704310964; Mon, 17 Aug 2020 15:45:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597704310; cv=none; d=google.com; s=arc-20160816; b=WvkxPWr+Q2M6buZUEXs36364/MrIHvGXqOXNTw2HpicNOGy40qkZPAN26PS9Ydgt2f 5tcDbVs55zkKhTTbLAHhRgwXBbsRVKJQyCEkx94IN0Af9UBiqYI24XPng4AntS+tzx91 wLfkuHWpwe6Vx2whKH32+Gsb+zO1BqzWC3mkJamLcIenlAj5ibA8VYIEvkatEQeoE6C6 PsLgTVtG/RQ5DfzL+afVYvoh9u7HhjuKQ6lXZOfepqM3e2Eyn8MwrMICqpDOvzLX57oY e4ar0w79MPbAgwLMGz8VsEYCIMcwHnLLaAAJjKSKVLFxn2owz8Em372xCQTgC+VrFH5/ vH/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GasWvn6NOOJnh1LtMWmUGAC7CEQcRJGj47mWlHs/ts8=; b=d9xjhWQkh3G5zsW+CJac75srEqtHinvpWXb1K1PDrV1UQYeE6L5w/tN6vvaJgqJgBb 25B3WgDPRJZPuxpVY7qDek5YdD3hyRMgSkUDmba9t4eGY9fg57g1PnP9smpJydHgsBUU 8UPpCD49V6eyNRCQwIKx1Pp/HSTvC1ERzFN/t35o9UjJpqqTq3BG1/k2uS2fwg+oAd5B Ma591iVNGFfX4zDfkYMPUOX3auLkBXGZtpzFAuvNJK1eVHpc8J3FzKlew6CBeCyYB92H 8SuqosT7w01xXI19sJh9Q9G70Fql4BmeRVIxZt6P9nktg+bwSmUsNVzCshMkKIFUdfzL oVPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0y5y9z0g; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bc16si11633190edb.394.2020.08.17.15.44.48; Mon, 17 Aug 2020 15:45:10 -0700 (PDT) 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=@kernel.org header.s=default header.b=0y5y9z0g; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731805AbgHQTLz (ORCPT + 99 others); Mon, 17 Aug 2020 15:11:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:50488 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730716AbgHQPlI (ORCPT ); Mon, 17 Aug 2020 11:41:08 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DF7C120825; Mon, 17 Aug 2020 15:41:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678868; bh=K1Ma8cAdRm4cq5FiYwAP+gpk459mF5A3ggKalD13s7U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0y5y9z0g5wHE9RfdzPupqS8rhx+uz5mpTxt0e3yMYfK2i/UCFc83bQmRa9Pc93L3u NKDRuaEjXymQCK04emfMT92pkGNEFR5JWR/GR+05jvii/Cf552B71HsStfD7zSfZ4x fkvd5+6JDbUgb86rApw9o4i5X8uSJ9zq0w5+g2Rs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Thierry Reding , Sasha Levin Subject: [PATCH 5.7 018/393] memory: tegra: Fix an error handling path in tegra186_emc_probe() Date: Mon, 17 Aug 2020 17:11:08 +0200 Message-Id: <20200817143820.472375761@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143819.579311991@linuxfoundation.org> References: <20200817143819.579311991@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe JAILLET [ Upstream commit c3d4eb3bf6ad32466555b31094f33a299444f795 ] The call to tegra_bpmp_get() must be balanced by a call to tegra_bpmp_put() in case of error, as already done in the remove function. Add an error handling path and corresponding goto. Fixes: 52d15dd23f0b ("memory: tegra: Support DVFS on Tegra186 and later") Signed-off-by: Christophe JAILLET Signed-off-by: Thierry Reding Signed-off-by: Sasha Levin --- drivers/memory/tegra/tegra186-emc.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/memory/tegra/tegra186-emc.c b/drivers/memory/tegra/tegra186-emc.c index 97f26bc77ad41..c900948881d5b 100644 --- a/drivers/memory/tegra/tegra186-emc.c +++ b/drivers/memory/tegra/tegra186-emc.c @@ -185,7 +185,7 @@ static int tegra186_emc_probe(struct platform_device *pdev) if (IS_ERR(emc->clk)) { err = PTR_ERR(emc->clk); dev_err(&pdev->dev, "failed to get EMC clock: %d\n", err); - return err; + goto put_bpmp; } platform_set_drvdata(pdev, emc); @@ -201,7 +201,7 @@ static int tegra186_emc_probe(struct platform_device *pdev) err = tegra_bpmp_transfer(emc->bpmp, &msg); if (err < 0) { dev_err(&pdev->dev, "failed to EMC DVFS pairs: %d\n", err); - return err; + goto put_bpmp; } emc->debugfs.min_rate = ULONG_MAX; @@ -211,8 +211,10 @@ static int tegra186_emc_probe(struct platform_device *pdev) emc->dvfs = devm_kmalloc_array(&pdev->dev, emc->num_dvfs, sizeof(*emc->dvfs), GFP_KERNEL); - if (!emc->dvfs) - return -ENOMEM; + if (!emc->dvfs) { + err = -ENOMEM; + goto put_bpmp; + } dev_dbg(&pdev->dev, "%u DVFS pairs:\n", emc->num_dvfs); @@ -237,7 +239,7 @@ static int tegra186_emc_probe(struct platform_device *pdev) "failed to set rate range [%lu-%lu] for %pC\n", emc->debugfs.min_rate, emc->debugfs.max_rate, emc->clk); - return err; + goto put_bpmp; } emc->debugfs.root = debugfs_create_dir("emc", NULL); @@ -254,6 +256,10 @@ static int tegra186_emc_probe(struct platform_device *pdev) emc, &tegra186_emc_debug_max_rate_fops); return 0; + +put_bpmp: + tegra_bpmp_put(emc->bpmp); + return err; } static int tegra186_emc_remove(struct platform_device *pdev) -- 2.25.1