Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3262307lfo; Mon, 23 May 2022 00:15:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6VBG7jNyCyhw4BRJ+ilUAoh/WRQ2mfdUHxyyfA6/TZqhD1QZShP2F0Fr+wiCC9lfIqdjz X-Received: by 2002:a63:904b:0:b0:3f8:4814:ecb4 with SMTP id a72-20020a63904b000000b003f84814ecb4mr12931591pge.257.1653290127344; Mon, 23 May 2022 00:15:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653290127; cv=none; d=google.com; s=arc-20160816; b=p6tMgS7IbZeuPeGCOABlkApmke1TkJuDdjxTzc8/DSyworr0b+JzZB0947oak5Iyp+ /y1U6I94sUVOtv9GU7AWSJdjsTaiz2G+zn7L4ekxyvUB0CF8vjHXt0bOvjaxDx2JM8XW /rQuVYvB9BLZJEuImWv0sdQLuahTnpB1HWjuDvc5d+DoC+bfB1P72xevRo0KAwjUAXEz uuLYQLGN3janQAY6km191BWfHaK9/3/fqsTsp/wfSn9xuXG2d2XLLZEYo9Q6ws8kxrAU BUKvh/h3GK3GiNLg+jN268Kt4Pfs9LlrsawLMQwxohxyH2KQ8ePRYQ+fdjT6GpRi0dt7 kOpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id; bh=/FfN0E3E77ZDU6Nb96G8OyiwD4hIyeDsUXQpeysJICo=; b=xQlS1gi62zEXB1U3Z0nSpRBnqaWl8+eZiQgGi6BYJ0tC7NGnONQiKbaZtKxt3EAsYN 2e1KaVPcmTUXPRtn4NmnaWr+kzNsX5YCsavRrm1SGZCWH++FYnGpD547hmP9EW8WD286 8VVOY2H2eHgNwn5FmfLYiDi9Ej0epOhA81nMBkKee/z93kPQlPA6ZPsMbuLCh4sTTk6+ SnigAeH5O6CB7eJARHED5n7KndQlfzb9+piy9+PTX2qFFdNA92rLdD2wf4pAtfwGn/Xd 3MgApyxzTzuMMlN2oB1CZ0JNwnpteOdMuuV5j/DFpfaZjSmSWgB1+aFuWc2G2AK/v49G 7s8g== 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:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x26-20020a63171a000000b003c648ddf7f7si5471559pgl.141.2022.05.23.00.15.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 00:15:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0EDB084A23; Sun, 22 May 2022 23:33:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232622AbiEUM2X (ORCPT + 99 others); Sat, 21 May 2022 08:28:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233731AbiEUM2V (ORCPT ); Sat, 21 May 2022 08:28:21 -0400 Received: from smtp.smtpout.orange.fr (smtp07.smtpout.orange.fr [80.12.242.129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A2A487203 for ; Sat, 21 May 2022 05:28:18 -0700 (PDT) Received: from [192.168.1.18] ([86.243.180.246]) by smtp.orange.fr with ESMTPA id sODMnGgnKL5fDsODMnUwId; Sat, 21 May 2022 14:28:16 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sat, 21 May 2022 14:28:16 +0200 X-ME-IP: 86.243.180.246 Message-ID: Date: Sat, 21 May 2022 14:28:11 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH] i2c: bcm2835: Fix error handling in bcm2835_i2c_probe Content-Language: en-US To: Wolfram Sang , Miaoqian Lin , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Nicolas Saenz Julienne , Stefan Wahren , Eric Anholt , Lad Prabhakar , Annaliese McDermond , linux-i2c@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20220403063310.7525-1-linmq006@gmail.com> From: Christophe JAILLET In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Le 21/05/2022 à 13:46, Wolfram Sang a écrit : > On Sun, Apr 03, 2022 at 06:33:08AM +0000, Miaoqian Lin wrote: >> In the error handling path, the clk_prepare_enable() function >> call should be balanced by a corresponding 'clk_disable_unprepare()' >> call. And clk_set_rate_exclusive calls clk_rate_exclusive_get(), >> it should be balanced with call to clk_rate_exclusive_put(). >> , as already done in the remove function. >> >> Fixes: bebff81fb8b9 ("i2c: bcm2835: Model Divider in CCF") >> Signed-off-by: Miaoqian Lin > > Looking for a reviewer here, pretty please? Hi, on which tree are you working? A similar patch is already available in -next since several months. (see [1]) CJ [1]: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/i2c/busses/i2c-bcm2835.c?id=b205f5850263632b6897d8f0bfaeeea4955f8663 > >> --- >> drivers/i2c/busses/i2c-bcm2835.c | 21 ++++++++++++++++----- >> 1 file changed, 16 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c >> index 5149454eef4a..d794448866a7 100644 >> --- a/drivers/i2c/busses/i2c-bcm2835.c >> +++ b/drivers/i2c/busses/i2c-bcm2835.c >> @@ -454,18 +454,21 @@ static int bcm2835_i2c_probe(struct platform_device *pdev) >> ret = clk_prepare_enable(i2c_dev->bus_clk); >> if (ret) { >> dev_err(&pdev->dev, "Couldn't prepare clock"); >> - return ret; >> + goto err_put_clk; >> } >> >> i2c_dev->irq = platform_get_irq(pdev, 0); >> - if (i2c_dev->irq < 0) >> - return i2c_dev->irq; >> + if (i2c_dev->irq < 0) { >> + ret = i2c_dev->irq; >> + goto err_disable_clk; >> + } >> >> ret = request_irq(i2c_dev->irq, bcm2835_i2c_isr, IRQF_SHARED, >> dev_name(&pdev->dev), i2c_dev); >> if (ret) { >> dev_err(&pdev->dev, "Could not request IRQ\n"); >> - return -ENODEV; >> + ret = -ENODEV; >> + goto err_disable_clk; >> } >> >> adap = &i2c_dev->adapter; >> @@ -489,8 +492,16 @@ static int bcm2835_i2c_probe(struct platform_device *pdev) >> >> ret = i2c_add_adapter(adap); >> if (ret) >> - free_irq(i2c_dev->irq, i2c_dev); >> + goto err_free_irq; >> + >> + return ret; >> >> +err_free_irq: >> + free_irq(i2c_dev->irq, i2c_dev); >> +err_disable_clk: >> + clk_disable_unprepare(i2c_dev->bus_clk); >> +err_put_clk: >> + clk_rate_exclusive_put(i2c_dev->bus_clk); >> return ret; >> } >> >> -- >> 2.17.1 >>