Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9396678pxu; Mon, 28 Dec 2020 15:08:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJxNhilFqr3z0FEG+XgEzsxFidRGe0w5dgqI3Tqx7Qn8lChFoVqdA2UqWI2hnPNPSHaTElyy X-Received: by 2002:a17:906:1ed6:: with SMTP id m22mr45073382ejj.231.1609196910010; Mon, 28 Dec 2020 15:08:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609196910; cv=none; d=google.com; s=arc-20160816; b=vc+5l74tVJWpA1kiUgVW9SBGAw39iEXMoGhfU0JEYNvYQ+Ous1z8Y05dykrj0sE0jU hqmLu50xTRCf2KH4lNZ0K0dX1X+MTqJLzeG/A+nHAft0m7ZCUlqO+P6Wu3QLo5CDKbnQ oXqsKmFc8/FmVUgiaPmbEh8SXCJcZXiTJqBHSoHtwTz/9vDhoqawyF6NhoDXQBZGdckw 94de9DOoU2F2JfLx+vrUak8rVLMDuWfyxyRtrBuHocZVbcvslCtPfrfcg8wghkiOYEu+ HbuRc+GtRrWeu9EEFDiNYI60wchWfk2zrKnUMn0NfXNk1cDPR1n0vnM5HWan7+7ojp3z kbYw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WB3fis+6lRqhqSppZgnzxGb5+tlFcdwiBDXs4+Lzs0c=; b=hBPtPPeXcqzTnppa2e99YDz1EgrI/6MfVVu+eJzSH+ZpYBO3Gaklawgushbrc+3HNz BC+qK8NQt5f1NN+9rXqmQaXrzhqWJZ6l5VLwy+06Bz7iI+mCRRaWYns9vifAxnJq/vCj ekqGZyJLHLZIM8RShq30dAwWrtCFv1bdNcTrtIRrWeDR8OwNTDt5gBY/YfvILHvGhTVj Q2ZiotBAMFEIqcWPoXFFs9tIHAa0YRVhyktRXZFJKNjF1k06GaFNmJDDMp0NagRdLpRJ T/lkxn0ylwkF7+Zf+nX8DFNrRF3qxLqUfFAiII4gG7iBAL4U0KrhEhaNCxp+RjSLckXG 3UuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uRa8nzuQ; 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=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 bt22si15931754ejb.107.2020.12.28.15.08.08; Mon, 28 Dec 2020 15:08:29 -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=@linuxfoundation.org header.s=korg header.b=uRa8nzuQ; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439627AbgL1OLZ (ORCPT + 99 others); Mon, 28 Dec 2020 09:11:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:44922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439222AbgL1OLA (ORCPT ); Mon, 28 Dec 2020 09:11:00 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id CF18D206D4; Mon, 28 Dec 2020 14:10:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164645; bh=djoh+KZa49Y8MAq1v+kB1czG/Imo+5uqgRP8l3YTr0s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uRa8nzuQwF87TfpP6uGUPBjc7qeWisTX/J3TljTq70y1QtCeELvMIb1lxRJbx53Uf YqCbAvIH/atJD/KwHAQyoGf1MCeqz0SWsfX8nDsY8HE1yi8Ygtu4fLQuLo/DukYk6T Ku1e9O6n03efHktmthDXmnCWQ6Smb4Z0lZvfyOHM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Qilong , Sasha Levin Subject: [PATCH 5.10 217/717] serial: 8250-mtk: Fix reference leak in mtk8250_probe Date: Mon, 28 Dec 2020 13:43:35 +0100 Message-Id: <20201228125031.373196857@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhang Qilong [ Upstream commit 6e4e636e0e3e0b5deffc5e233adcb2cd4e68f2d0 ] The pm_runtime_enable will increase power disable depth. Thus a pairing decrement is needed on the error handling path to keep it balanced according to context. Fixes: e32a83c70cf98 ("serial: 8250-mtk: modify mtk uart power and clock management") Signed-off-by: Zhang Qilong Link: https://lore.kernel.org/r/20201119141126.168850-1-zhangqilong3@huawei.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/8250/8250_mtk.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c index fa876e2c13e5d..f7d3023f860f0 100644 --- a/drivers/tty/serial/8250/8250_mtk.c +++ b/drivers/tty/serial/8250/8250_mtk.c @@ -572,15 +572,22 @@ static int mtk8250_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); err = mtk8250_runtime_resume(&pdev->dev); if (err) - return err; + goto err_pm_disable; data->line = serial8250_register_8250_port(&uart); - if (data->line < 0) - return data->line; + if (data->line < 0) { + err = data->line; + goto err_pm_disable; + } data->rx_wakeup_irq = platform_get_irq_optional(pdev, 1); return 0; + +err_pm_disable: + pm_runtime_disable(&pdev->dev); + + return err; } static int mtk8250_remove(struct platform_device *pdev) -- 2.27.0