From patchwork Mon Oct 24 11:30:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9616 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp531228wru; Mon, 24 Oct 2022 09:06:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4xu0wrxL22lHZoBAn2Yj8yLt8VL+/b6jgSQ28hvYYXe3HQBEVvGaNLDyXzs7y0Kz4Y776i X-Received: by 2002:aa7:df94:0:b0:461:aff8:d3e1 with SMTP id b20-20020aa7df94000000b00461aff8d3e1mr7399558edy.10.1666627572126; Mon, 24 Oct 2022 09:06:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666627572; cv=none; d=google.com; s=arc-20160816; b=PcK+oOxe81eoIirqY9Oe1QQ8JQmB3D6Xgi7P+3SMWihbhIctHqV+2kWxlK9HRRoXB+ oSrhIkTu/Z7J/oqI/f6jdXDm1l1anzlMzsljw0O0/g5Y4AjCbx9EpN6cgTkNUS2AW3/v PUG9T0I+9TOcK5xwa2Qb5SELmKrxfTTzUoNdU9HSRoifDAQfBp1kBTxvXpK1aQOwKxYP 7AO+mEQe8+7XOLMGWwJ9e5JFFRXBmGHUTqk54NXVY6GKlz8NdskxTUFi9KefBkdMjlgu Zr0WAKSffTR2BJ1LNvwytu3nJpZ2TjE1NMK8+ufXz/6w6HTcRspAE/QCwWLov2XOFZv+ QIcQ== 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=fcI3k15DIZHI6L/UoW0KlIMKvdVwbLy0Lc8HivKBdx8=; b=sD0BIu8jWXK3DQdzD2VVmNPYlV/SmVlE+bFsp+4hTTiyVxfGjrduL+Tcs9jzSxW5bB F7d5ydWdx7PxwrpqcUqfaQsIv0+7wl5tiKdZIfFQoRU7i1CqLsGtnDru+PTnZoXfhXDo d4m3jX73lXb3V6a7ABtI5JQougZ653jpWvYsZjRn3qzwwrwNt+0R1+q+F4CrJ0zL9OIE EYBcB874eT+QDCT/FD8rUTpPHCn3sffQXbVwG5IxGDmLaF7hlzHRO0uNpmhC8i7UxMSn zFHt8IuwKQ1wKXnFPZCRIIhnYCsfLph9ubDETt5g3VIAQbkflyC7nmdq97OVrgFRzpNt RC3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y26FXCt6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bd24-20020a056402207800b00447d6f244c6si127740edb.248.2022.10.24.09.05.45; Mon, 24 Oct 2022 09:06:12 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y26FXCt6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232840AbiJXQDr (ORCPT + 99 others); Mon, 24 Oct 2022 12:03:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232710AbiJXQCg (ORCPT ); Mon, 24 Oct 2022 12:02:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93138176BA9; Mon, 24 Oct 2022 07:55:53 -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 41E36B81188; Mon, 24 Oct 2022 12:26:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B513C433D6; Mon, 24 Oct 2022 12:26:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614408; bh=72IdrIRDfHiRyzadDUK1d/TKQj32QPvspPY4OjhOf2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y26FXCt6FMfQjgA9Sg+ZhIphX+7li+fn9ty1Kg3OaGl2+p0ZUIOqK/03aMBuhYuKn fgbL33MVFsYRwCPyOmtui+hzwkfJ/hWdOS104/w9nFpyjh6WH/0VhmJfw2rRD3A7hY kDEIVFE865zCDwjQn4G1IMWourlXKAuCKbIP6AUk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Lee Jones , Sasha Levin Subject: [PATCH 5.10 248/390] mfd: fsl-imx25: Fix an error handling path in mx25_tsadc_setup_irq() Date: Mon, 24 Oct 2022 13:30:45 +0200 Message-Id: <20221024113033.415359656@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747585672736535455?= X-GMAIL-MSGID: =?utf-8?q?1747585672736535455?= From: Christophe JAILLET [ Upstream commit 3fa9e4cfb55da512ebfd57336fde468830719298 ] If devm_of_platform_populate() fails, some resources need to be released. Introduce a mx25_tsadc_unset_irq() function that undoes mx25_tsadc_setup_irq() and call it both from the new error handling path of the probe and in the remove function. Fixes: a55196eff6d6 ("mfd: fsl-imx25: Use devm_of_platform_populate()") Signed-off-by: Christophe JAILLET Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/d404e04828fc06bcfddf81f9f3e9b4babbe35415.1659269156.git.christophe.jaillet@wanadoo.fr Signed-off-by: Sasha Levin --- drivers/mfd/fsl-imx25-tsadc.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/mfd/fsl-imx25-tsadc.c b/drivers/mfd/fsl-imx25-tsadc.c index a016b39fe9b0..95103b2cc471 100644 --- a/drivers/mfd/fsl-imx25-tsadc.c +++ b/drivers/mfd/fsl-imx25-tsadc.c @@ -84,6 +84,19 @@ static int mx25_tsadc_setup_irq(struct platform_device *pdev, return 0; } +static int mx25_tsadc_unset_irq(struct platform_device *pdev) +{ + struct mx25_tsadc *tsadc = platform_get_drvdata(pdev); + int irq = platform_get_irq(pdev, 0); + + if (irq) { + irq_set_chained_handler_and_data(irq, NULL, NULL); + irq_domain_remove(tsadc->domain); + } + + return 0; +} + static void mx25_tsadc_setup_clk(struct platform_device *pdev, struct mx25_tsadc *tsadc) { @@ -171,18 +184,21 @@ static int mx25_tsadc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, tsadc); - return devm_of_platform_populate(dev); + ret = devm_of_platform_populate(dev); + if (ret) + goto err_irq; + + return 0; + +err_irq: + mx25_tsadc_unset_irq(pdev); + + return ret; } static int mx25_tsadc_remove(struct platform_device *pdev) { - struct mx25_tsadc *tsadc = platform_get_drvdata(pdev); - int irq = platform_get_irq(pdev, 0); - - if (irq) { - irq_set_chained_handler_and_data(irq, NULL, NULL); - irq_domain_remove(tsadc->domain); - } + mx25_tsadc_unset_irq(pdev); return 0; }