From patchwork Mon Oct 24 11:31:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8830 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp431402wru; Mon, 24 Oct 2022 05:43:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4HVoFvBIDifDPcsLLRRvmguy52Kk8G2ztQ5F088rKXbuliWK9y4KLqkRhc/yqb927W5PL7 X-Received: by 2002:a05:6402:528a:b0:454:8613:6560 with SMTP id en10-20020a056402528a00b0045486136560mr31716126edb.252.1666615419956; Mon, 24 Oct 2022 05:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615419; cv=none; d=google.com; s=arc-20160816; b=WXQLZLZmtvNuv4ltOOz83wVbkG2cJEIMukyAbicY5REgZneVWwTrgnuT4CWTPj49LL zWpV0rM3fKVacoj0D7qpV7kqiIsQ1FQZ2hjQZX7JtdPtLc/+Y7OAy+tbtZs2BEAROKi5 QmvUl0PXhkQ9kBjch1tIYP1oxi1TkhYPQa02/Snj95p1BeQ63KN2elYK0Z8+8cen9kuT bSlAz2Ta9SqjqOSrfBdSI/FBzbN+4XIHCOW/84vv+Mc9KN7cmzuFegVFyMbh2nbcGyr8 MrqDhBi0SDa9f2/BzqxHJJNix2TzegjGCD8S1WzhHOEcY3Su7ID4HS53aNA8Ca76D9i8 96GQ== 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=Fit0RLNj5f7rs5ZT5x0BcOdXZxV6K9jw8fsGsFavINM=; b=w3Z2VXqIr1PuPh8bHN/Nk8fcvkj2wR0bEHjqMf8Pdc6yeUbVWNIcWBsH2Zj5zlAhAL IV7sG1KDkYz+u1yX3u9JUZv6Ck7Enx4sfPdQbBdjCgG23xnRkNnHF4cSXeZhB62Ib1B0 kMy13q4nxXZY+7gimj+k55+dUJ4ZsblcG+zTKyZajcRFdFCm83UMHjI2Do4IJjt9fnpB QpWMbyuLnD+PxFU5hmhmqJEVKmM5TmOe5DB5m3myVW+i++Gk9IjllYjvMW7XH0L79ccr gIBQnlqOsZhaPr9Hpz7ZXz7Ul4QFCL+7WgT3XdSq8h6lT8cumftApaasjfnQEgUGvB96 qmzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v+SlfBvK; 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 h3-20020a0564020e8300b00461c852af19si2571809eda.633.2022.10.24.05.43.06; Mon, 24 Oct 2022 05:43:39 -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=v+SlfBvK; 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 S232582AbiJXMhC (ORCPT + 99 others); Mon, 24 Oct 2022 08:37:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234462AbiJXMaY (ORCPT ); Mon, 24 Oct 2022 08:30:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB145AE73; Mon, 24 Oct 2022 05:04:36 -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 CFBCBB81199; Mon, 24 Oct 2022 12:01:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31718C433D6; Mon, 24 Oct 2022 12:01:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612888; bh=kwySQ/fNngrpXZFgbjUEf/ovc1grJsREpVvSQtKuUJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v+SlfBvKEDx2HQIQjJjyGUDYRe8+/6LzCdlaQC8TFebthnt6KUWaODGRgq9AgBYop 4rLfwWyfzEEbOASGB2py+ea1Y1ETdfQDkoniuoVuYh8tvvAfy+HzWIiMJCraBoi+iT 7Jh2q71l4VpDkeQex6eoUHcxIDZnEsmPh+zvdZ90= 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 4.19 150/229] mfd: fsl-imx25: Fix an error handling path in mx25_tsadc_setup_irq() Date: Mon, 24 Oct 2022 13:31:09 +0200 Message-Id: <20221024113003.863134607@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@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?1747572930965599037?= X-GMAIL-MSGID: =?utf-8?q?1747572930965599037?= 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 dbb85caaafed..2718fcb26786 100644 --- a/drivers/mfd/fsl-imx25-tsadc.c +++ b/drivers/mfd/fsl-imx25-tsadc.c @@ -89,6 +89,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) { @@ -176,18 +189,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; }