From patchwork Thu Apr 27 18:19:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 677669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6296C77B73 for ; Thu, 27 Apr 2023 18:20:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244484AbjD0SUH (ORCPT ); Thu, 27 Apr 2023 14:20:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231577AbjD0SUF (ORCPT ); Thu, 27 Apr 2023 14:20:05 -0400 Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B86DC30F6; Thu, 27 Apr 2023 11:20:02 -0700 (PDT) Received: by mail-qv1-xf2a.google.com with SMTP id 6a1803df08f44-5ef55901f49so39152116d6.2; Thu, 27 Apr 2023 11:20:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682619602; x=1685211602; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AGaeocdiEgYYiyV9F2iOmV2bIeU06kUvSa9gWNEQaAQ=; b=CncbTud9qhe+DcKJhNq26tn506iRUu1rMfKkLCE2b8/U1gJkBqgfQ6/Ijmj74d/X4t ubcEUUmkWIPVBs7mBIuasRcDauhw51OQbgAFB9Dot1F/ZEAD8FnUt+F3hmuy5oxHmvTo Gfsu1/aWMx/SpPRClRUGf9iFhJFJyXdYUJhrfgAvQW09kgRo9ZAwHu0+b2naM+UoO2MH h4VqjwYrPZPpE+5OZKh3Sw8wpLJD+6QvdnYOW2CdSRysOvNQUClVEpKEpOHItrG/pH7z n4BH3dXTY/WKVp/MYhvjMHHPElYRx0py3WK1Tpn+6ShvW/97Le6gz+j+fMk/XXhzrJ9a KmJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682619602; x=1685211602; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AGaeocdiEgYYiyV9F2iOmV2bIeU06kUvSa9gWNEQaAQ=; b=UAANzka0m0t8X09pjegn1GERUfh+L/3yV6YYaFWIKI9B/q4gXrJjZGEXJIUvzOPU/p tNXCTnczm/nvos/nxcqSmEaphcCIN4K8UJ9Ytm7Xmdj7BFyksAQvRAlYYbpqR6ubZCQ4 TYOQQZwewBHiQHZGF++nr1yElxaK7nvaVoWc8Fvqv1n1DYpryOUuFGappQqkn6b0QOZ4 lux0AgjCT+bxZy099WMaRMWmts5DokkXSp5QQiA2sJU/xv1gD1sMxZMUW50CZ5Z4UdBM dtey5w7+5y6ujdyREe1eiaPNv8bD6HMSnHGdnoIf3WCw/T3ZVhhQEbjvI/dLSt3hOjHU fFhA== X-Gm-Message-State: AC+VfDzvZ7A3P92u7heaCrPzu6Y9xBucuhbqp43hhOcEGSZj9QQtR+// 9uccogYp39u5f0Y4Jj/rqJ0= X-Google-Smtp-Source: ACHHUZ4i3llp4kr7De3qtTeEe/6ksRlGqIo0MkjYvKYBHzrH1nYjOwTETcvxkzY0G2MsJbJkc3bpxg== X-Received: by 2002:ad4:5e89:0:b0:613:5d6a:94f6 with SMTP id jl9-20020ad45e89000000b006135d6a94f6mr4226699qvb.19.1682619601781; Thu, 27 Apr 2023 11:20:01 -0700 (PDT) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id s14-20020a0cdc0e000000b005e5b30eef24sm5788316qvk.56.2023.04.27.11.19.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 11:20:01 -0700 (PDT) From: Doug Berger To: Greg Kroah-Hartman Cc: Al Cooper , XuDong Liu , Dongliang Mu , Jiri Slaby , Florian Fainelli , Broadcom internal kernel review list , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe JAILLET , Doug Berger Subject: [PATCH 1/2] serial: 8250_bcm7271: balance clk_enable calls Date: Thu, 27 Apr 2023 11:19:15 -0700 Message-Id: <20230427181916.2983697-2-opendmb@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230427181916.2983697-1-opendmb@gmail.com> References: <20230427181916.2983697-1-opendmb@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org The sw_baud clock must be disabled when the device driver is not connected to the device. This now occurs when probe fails and upon remove. Fixes: 41a469482de2 ("serial: 8250: Add new 8250-core based Broadcom STB driver") Reported-by: XuDong Liu Link: https://lore.kernel.org/lkml/20230424125100.4783-1-m202071377@hust.edu.cn/ Signed-off-by: Doug Berger Acked-by: Florian Fainelli --- drivers/tty/serial/8250/8250_bcm7271.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_bcm7271.c b/drivers/tty/serial/8250/8250_bcm7271.c index f801b1f5b46c..90ee7bc12f77 100644 --- a/drivers/tty/serial/8250/8250_bcm7271.c +++ b/drivers/tty/serial/8250/8250_bcm7271.c @@ -1032,7 +1032,7 @@ static int brcmuart_probe(struct platform_device *pdev) if (clk_rate == 0) { dev_err(dev, "clock-frequency or clk not defined\n"); ret = -EINVAL; - goto release_dma; + goto err_clk_disable; } dev_dbg(dev, "DMA is %senabled\n", priv->dma_enabled ? "" : "not "); @@ -1119,6 +1119,8 @@ static int brcmuart_probe(struct platform_device *pdev) serial8250_unregister_port(priv->line); err: brcmuart_free_bufs(dev, priv); +err_clk_disable: + clk_disable_unprepare(baud_mux_clk); release_dma: if (priv->dma_enabled) brcmuart_arbitration(priv, 0); @@ -1133,6 +1135,7 @@ static int brcmuart_remove(struct platform_device *pdev) hrtimer_cancel(&priv->hrt); serial8250_unregister_port(priv->line); brcmuart_free_bufs(&pdev->dev, priv); + clk_disable_unprepare(priv->baud_mux_clk); if (priv->dma_enabled) brcmuart_arbitration(priv, 0); return 0; From patchwork Thu Apr 27 18:19:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 679722 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62F65C77B7E for ; Thu, 27 Apr 2023 18:20:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244418AbjD0SUJ (ORCPT ); Thu, 27 Apr 2023 14:20:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244429AbjD0SUH (ORCPT ); Thu, 27 Apr 2023 14:20:07 -0400 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7C79449A; Thu, 27 Apr 2023 11:20:04 -0700 (PDT) Received: by mail-qv1-xf2b.google.com with SMTP id 6a1803df08f44-5ef8af5d211so68128706d6.3; Thu, 27 Apr 2023 11:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682619604; x=1685211604; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M3ybj49I0azNPq8mUJZxYJ7OaIdhKs0dZovAgS2rqE8=; b=U89HRMpmyZlcTTn96nVf6SFQOC43UMedTYIBj2PDadzSbWoo792cepjuYgCy9eXraJ MQqMMxvgMRxDDehnECB6pWT3pfAJYJqZK0dRfqBl+dw+QQTYS5ESUlhlikynsPChclad +ENs6hONhfCZ/hCQsha4vW28bgnCF9b48fBosFRrqgNZrlxTuzPWOyEjfkerrCHW+XsF t/cEk6NEYeoij5WzgaH+Ym0eaYUVFEIENQLnZ0NtxhZawULOn0rE8Rp/z+mBCwBO127a NU9N21v8CVfN65WuOYWzQlFJ8NFGCQqBQy9IKwLRXg7k/sTEEIN2Ivx1KGD9xL5AFiSB h9qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682619604; x=1685211604; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M3ybj49I0azNPq8mUJZxYJ7OaIdhKs0dZovAgS2rqE8=; b=DFDiaurqMtRY2T0oNlYdr0qRX/zrI3f3GOL3nC0EXwc5WwFTL+J2mrccCExigxQDvN ObiBv1SmK/elOyJZcDPUTxqlq+yeqMdCDuVvi5TeGmHU4cVedMTTR8tRe15873OuUv1T 2dlnarJefeZdLjKvV3ZeIW9oj+rajL+lklmgDOBqe4CBQZUgXzSr8DNQpgVwJFN2R5WV M15jndHfKzb+Ex3UDuFWgv8v37XoV358EsvvablVigMhJrWifqWSA82n3CYx0IPdHRUX ckDHth/KHUtTcm3nQ6AOWslysLzk0AiYnGTcB8Jh9BLenLKVAs9YrwrH75s9s26hlpBT HRTQ== X-Gm-Message-State: AC+VfDwaHqrjclkzVY4Xc4+C0QSRtREByg9V+1nCYlNA/JYEDQ8+oQ0v I7rOgaM8ZJ5GNAaenbUqlXo= X-Google-Smtp-Source: ACHHUZ5cYl3jgQZm6SGSvJtiMMs2doLTMTbPU0Kv/GWLf+po8Dd7JG/XRhHNP9301io5yiD2i8lx+Q== X-Received: by 2002:a05:6214:5015:b0:5dd:aee7:dffb with SMTP id jo21-20020a056214501500b005ddaee7dffbmr3785649qvb.22.1682619603698; Thu, 27 Apr 2023 11:20:03 -0700 (PDT) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id s14-20020a0cdc0e000000b005e5b30eef24sm5788316qvk.56.2023.04.27.11.20.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 11:20:03 -0700 (PDT) From: Doug Berger To: Greg Kroah-Hartman Cc: Al Cooper , XuDong Liu , Dongliang Mu , Jiri Slaby , Florian Fainelli , Broadcom internal kernel review list , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe JAILLET , Doug Berger Subject: [PATCH 2/2] serial: 8250_bcm7271: fix leak in `brcmuart_probe` Date: Thu, 27 Apr 2023 11:19:16 -0700 Message-Id: <20230427181916.2983697-3-opendmb@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230427181916.2983697-1-opendmb@gmail.com> References: <20230427181916.2983697-1-opendmb@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Smatch reports: drivers/tty/serial/8250/8250_bcm7271.c:1120 brcmuart_probe() warn: 'baud_mux_clk' from clk_prepare_enable() not released on lines: 1032. The issue is fixed by using a managed clock. Fixes: 41a469482de2 ("serial: 8250: Add new 8250-core based Broadcom STB driver") Reported-by: XuDong Liu Link: https://lore.kernel.org/lkml/20230424125100.4783-1-m202071377@hust.edu.cn/ Signed-off-by: Doug Berger --- drivers/tty/serial/8250/8250_bcm7271.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_bcm7271.c b/drivers/tty/serial/8250/8250_bcm7271.c index 90ee7bc12f77..af0e1c070187 100644 --- a/drivers/tty/serial/8250/8250_bcm7271.c +++ b/drivers/tty/serial/8250/8250_bcm7271.c @@ -1012,7 +1012,7 @@ static int brcmuart_probe(struct platform_device *pdev) of_property_read_u32(np, "clock-frequency", &clk_rate); /* See if a Baud clock has been specified */ - baud_mux_clk = of_clk_get_by_name(np, "sw_baud"); + baud_mux_clk = devm_clk_get(dev, "sw_baud"); if (IS_ERR(baud_mux_clk)) { if (PTR_ERR(baud_mux_clk) == -EPROBE_DEFER) { ret = -EPROBE_DEFER;