Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3513688pxm; Mon, 28 Feb 2022 23:01:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRlLI7ws2P5gScah/S4kPzoIGpjwMvg9j0Yn/Ql5jRLtTvSCq9u2gO7sYb9uEn6i11/pyP X-Received: by 2002:a17:907:7711:b0:6ce:e03c:e1e2 with SMTP id kw17-20020a170907771100b006cee03ce1e2mr18042888ejc.769.1646118079575; Mon, 28 Feb 2022 23:01:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646118079; cv=none; d=google.com; s=arc-20160816; b=W7jZTCeZArZoneSBL8j6QO6UE30IEU4yzt3ihkcUpTvbeOj8kasDwlMubTPX9vLJ7V 8fbVryYv0uWkqFuHh/w1ahZebCv6GC27jnZXxYrY6pxzB7NdSKu9AN9GSnhHAH3RGhlE ywanV4v87hBllGplAAozht7I5llVZFELzGIo8U3JQ+lv/6ZVqGaRcKz1zu8hQhUpauE7 jCQGBZHRdKeMWYtS9sD2cIKh177+8TL0sn2gdy+S1dCTnwo7L/TyMjk0l89dkWJ73Wqq TU0F+KXdOIX/woYeS4oOwYVfEMjTlHJDUuGbxFh3OBMYbM8iqLS9CJz1AnBH8vVMs99X nv8w== 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 :message-id:date:subject:cc:to:from; bh=mlT4kf5En3L7H0DgqPzmVAD20QeqLJx6A6dlG3dXQUQ=; b=b7eVLPcZybCcYkk8Q+ydO9owr8g8Yvc1MIeCDJjTzg80Rn9rAGWALegKR7pCbapdjQ +gERG0hPLp7KNTc1rRjNC7JglHBU51OBuPPw3bH5+rNtYwMml1ksYvv1AUVgUOUi8kuB T4Ah+/mjtKuH22uOGNUo3QE4YgByT48lvHW3u8f5Y7ak9oHz1nik3cZxBrbSJExXFdXs j/LKPEdc8Qr0yuW6i7DnJI8CxB81diJ+NNJe+MDiWZ4163sS0lG94swfR/X9Eum838Ra hJrAJwLEVgbjYUlAAjQ7t5ILWcEATifoJ+NH5JYVXZMK44c4eWJ9H/lPBhJkjLfgB8Wa +isw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c18-20020a056402121200b0041531b087fasi386947edw.550.2022.02.28.23.00.56; Mon, 28 Feb 2022 23:01:19 -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 S230259AbiCAFjY (ORCPT + 99 others); Tue, 1 Mar 2022 00:39:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232515AbiCAFjV (ORCPT ); Tue, 1 Mar 2022 00:39:21 -0500 Received: from mail-sh.amlogic.com (mail-sh.amlogic.com [58.32.228.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDA614B1D9; Mon, 28 Feb 2022 21:38:37 -0800 (PST) Received: from droid06.amlogic.com (10.18.11.248) by mail-sh.amlogic.com (10.18.11.5) with Microsoft SMTP Server id 15.1.2176.14; Tue, 1 Mar 2022 13:38:35 +0800 From: Yu Tu To: , , , CC: Greg Kroah-Hartman , Jiri Slaby , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Yu Tu , kernel test robot , Dan Carpenter Subject: [PATCH] tty: serial: meson: Fixed an issue where pclk was turned on on probe but should be turned off on subsequent errors. Date: Tue, 1 Mar 2022 13:37:38 +0800 Message-ID: <20220301053738.21163-1-yu.tu@amlogic.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.18.11.248] X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Call clk_prepare_enable in the probe function to enable pclk. If you exit the probe function later in an error, call clk_disable_unprepare to disable pclk. Fixes: 44023b8e1f14 ("tty: serial:meson: Describes the calculation of the UART baud rate clock using a clock frameā€œ) Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: Yu Tu --- drivers/tty/serial/meson_uart.c | 37 +++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c index bf6be5468aaf..972f210f3492 100644 --- a/drivers/tty/serial/meson_uart.c +++ b/drivers/tty/serial/meson_uart.c @@ -780,28 +780,37 @@ static int meson_uart_probe(struct platform_device *pdev) return ret; irq = platform_get_irq(pdev, 0); - if (irq < 0) - return irq; + if (irq < 0) { + ret = irq; + goto err_out_clk_disable; + } of_property_read_u32(pdev->dev.of_node, "fifo-size", &fifosize); if (meson_ports[pdev->id]) { dev_err(&pdev->dev, "port %d already allocated\n", pdev->id); - return -EBUSY; + ret = -EBUSY; + goto err_out_clk_disable; } port = devm_kzalloc(&pdev->dev, sizeof(struct uart_port), GFP_KERNEL); - if (!port) - return -ENOMEM; + if (!port) { + ret = -ENOMEM; + goto err_out_clk_disable; + } port->membase = devm_ioremap_resource(&pdev->dev, res_mem); - if (IS_ERR(port->membase)) - return PTR_ERR(port->membase); + if (IS_ERR(port->membase)) { + ret = PTR_ERR(port->membase); + goto err_out_clk_disable; + } private_data = devm_kzalloc(&pdev->dev, sizeof(*private_data), GFP_KERNEL); - if (!private_data) - return -ENOMEM; + if (!private_data) { + ret = -ENOMEM; + goto err_out_clk_disable; + } if (device_get_match_data(&pdev->dev)) private_data->use_xtal_clk = true; @@ -822,7 +831,7 @@ static int meson_uart_probe(struct platform_device *pdev) ret = meson_uart_probe_clocks(port); if (ret) - return ret; + goto err_out_clk_disable; meson_ports[pdev->id] = port; platform_set_drvdata(pdev, port); @@ -831,9 +840,15 @@ static int meson_uart_probe(struct platform_device *pdev) meson_uart_reset(port); ret = uart_add_one_port(&meson_uart_driver, port); - if (ret) + if (ret) { meson_ports[pdev->id] = NULL; + goto err_out_clk_disable; + } + + return 0; +err_out_clk_disable: + clk_disable_unprepare(pclk); return ret; } base-commit: d4ab5487cc77a4053dc9070c5761ad94bf397825 -- 2.33.1