Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp966142pxb; Wed, 6 Apr 2022 05:31:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTBaiA4H3hexyEVMTC4zWKnXcHq0y+1LKWA8k9TC+XD+VkyR4vc5QxTEPBj5LgTSAi1kdC X-Received: by 2002:a17:90a:3b47:b0:1ca:7075:124e with SMTP id t7-20020a17090a3b4700b001ca7075124emr9766002pjf.209.1649248318587; Wed, 06 Apr 2022 05:31:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649248318; cv=none; d=google.com; s=arc-20160816; b=XsCiVl1iBxFkiUBz5R+n3EqWTLPBIYlpVRWjvuBjOChRn7JLlsGkNCmYJPxUR4375f TQ0Vf4yYKZF1+Yt0QPlnezqDcueL19M2W7Wv45D5Atza4F6ugaL1nv4JwrG/hzZsaNqX sU4WTlIFp8NbFsBLBHogBufLRh+dxL4iMdp2jH4oQuQ74IZqF5glyrAb2ZEg7w6J89Xx ElpRyPslMGeScutsI7TS7JrisY+mn5GB+DS7n03+zT58Fb+z0xTPrDyZiUhLIpkZwIRJ /P5Q0a0BD5nj96z2amjDuqFWx6C10xr77emyOCgBYZqwZaWw5XQYTSvM5OZ4QmOWSYvj BVPQ== 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=b7lK3dsfcWdICVh6v70wabAyZWvqyFVTzCHSltRhHn4=; b=flnAQtb9gKh0E7za2/ss8VH8Yz2D9FiU+2CWdLIUZ9Zy/h2xVF2qiG/M9rNgRe3mJh /Ep7Izrt0gSpRmMQwbh1L88VuMuAVGio9mGTNFPhJqQRPMcqeypicWhsa6V6furT9gnc V5X1bp4ykhHNI05hj9W3BhW2C38JBa4Ey+oqLWDiZg5EWYTT3Uh1BaVBZr3xtMjRfeOZ 2EiQfxU8j/ojRHmDMziV08WAD91gAVNnSZiShfdIfw3P8osCJZlY+qmerukS5SDqYaNO JBtP5wGlo7cBleQRZRgfZydh60JhT2Pi/p/rfe0nojhlm/+GOy0Q0ph39qg2Og7qFerE TRFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lGNkXHpS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q37-20020a635065000000b00398fe641fd3si12059070pgl.705.2022.04.06.05.31.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:31:58 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lGNkXHpS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 469FC4F7ADF; Wed, 6 Apr 2022 02:12:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1454985AbiDEXX3 (ORCPT + 99 others); Tue, 5 Apr 2022 19:23:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348964AbiDEJsu (ORCPT ); Tue, 5 Apr 2022 05:48:50 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DE79A0BD3; Tue, 5 Apr 2022 02:38:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E00B7B81B7F; Tue, 5 Apr 2022 09:38:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E060C385A2; Tue, 5 Apr 2022 09:38:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151496; bh=QwLQUT2Jw7vwffeh6OOnj7GZe0N18ZdeXGnosRVYSSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lGNkXHpS534sPY4Q13kyXMIIoEHDGbOdLxWE9CZ5DR3SO7cK2mteHbG6I36dG2If/ hyZKhI8lBcIdh7c3YPvHQmALB9BzOujVt0Rwwwve8t0iCV7g8WEq0eaCm1hC+ndoBC IqNfGWxwBZwHraI7jgQlUNFHPa8R/sAM1/53CW6w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Wolfram Sang , Sasha Levin Subject: [PATCH 5.15 436/913] i2c: bcm2835: Fix the error handling in bcm2835_i2c_probe() Date: Tue, 5 Apr 2022 09:24:58 +0200 Message-Id: <20220405070352.915051749@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Christophe JAILLET [ Upstream commit b205f5850263632b6897d8f0bfaeeea4955f8663 ] Some resource should be released if an error occurs in 'bcm2835_i2c_probe()'. Add an error handling path and the needed 'clk_disable_unprepare()' and 'clk_rate_exclusive_put()' calls. While at it, rework the bottom of the function to use this newly added error handling path and have an explicit and more standard "return 0;" at the end of the normal path. Fixes: bebff81fb8b9 ("i2c: bcm2835: Model Divider in CCF") Signed-off-by: Christophe JAILLET [wsa: rebased] Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- 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..f72c6576d8a3 100644 --- a/drivers/i2c/busses/i2c-bcm2835.c +++ b/drivers/i2c/busses/i2c-bcm2835.c @@ -454,18 +454,20 @@ 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_exclusive_rate; } 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_unprepare_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; + goto err_disable_unprepare_clk; } adap = &i2c_dev->adapter; @@ -489,7 +491,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 0; + +err_free_irq: + free_irq(i2c_dev->irq, i2c_dev); +err_disable_unprepare_clk: + clk_disable_unprepare(i2c_dev->bus_clk); +err_put_exclusive_rate: + clk_rate_exclusive_put(i2c_dev->bus_clk); return ret; } -- 2.34.1