Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp845411pxb; Wed, 6 Apr 2022 01:41:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPelAVU+AfBW50srsfN0jMemmme2nSGzVutCaG+s9oHK2q+yDpzgqVm/4Dgxp9hIu4A56L X-Received: by 2002:a05:6a00:724:b0:4fa:a35f:8e0f with SMTP id 4-20020a056a00072400b004faa35f8e0fmr7755281pfm.25.1649234498976; Wed, 06 Apr 2022 01:41:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649234498; cv=none; d=google.com; s=arc-20160816; b=oKpT4dhwA/95D/cbsL9m9vT47mGVe+OlZiymNk+A7GEX45l5+6RcGqm9Vf7rB1uBGH eNqHabrBn5n4OltmSiH9Ds6787snp+JsslVvRis0e2uuv5t9dCyoWSOorlbz7XUJkJ3h XeC/DXsej79d+RhvOouKQu6y4cbonZp2JEeAsGnA7b4L9283Or6oo2NgCtaiqsm6J6hs 7C6ZzMmPJZOHqPMOyhgghvYkJNrb6heJZrn/WX53E6Q9CSrNcPwqhaDzfjLeWGGJHlR/ cGqqNs8ayRgsNAI5FuzuqrNi14WfBf4MmoL4Xs9gExPRKA7gPc2Ra71xnXOZF/eq4ppy S8Xw== 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=CNW9stNlrm7otT2nREGZD75M7K13ydIFz9oiCXLrxAo=; b=w5rzBtWMMurr4n6NZz7tB4q+JlsoxzDDtiFcV+vNrmB1du+z3ZPCqol+lqvzvuTRs0 hz0GFk4HTwafdPyapmZLrB0Ix3e1s/RLqnsLZwRAkhdtblZaaC1C8TWCFN8OU6rTryPI jiFpjnhONjhLf50UkLBrdqciBOJHOH9a80z4Babr8gml1KN8mfFJzS+H22rf63OW0gda WgDMIXI9hAmG+Rt2bZaozfafbR/hFBUDTQfxd0thq1X/ky/0AzanUINNOPdirHpRS+3e 0auWt2ZMpSz7p19S2RCLAnQhBBT//sN/IaBixlOOXcuwVRl62fFEj6uwfoaMkmU11HPd NL/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YQqxpVbC; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id d12-20020a170903230c00b00153b2d165c2si6416542plh.458.2022.04.06.01.41.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 01:41:38 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YQqxpVbC; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 1FB925777BF; Wed, 6 Apr 2022 01:26:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1583634AbiDEXx2 (ORCPT + 99 others); Tue, 5 Apr 2022 19:53:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348614AbiDEJsH (ORCPT ); Tue, 5 Apr 2022 05:48:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CE253136C; Tue, 5 Apr 2022 02:34:18 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 99BA4616D5; Tue, 5 Apr 2022 09:34:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD2E2C385A4; Tue, 5 Apr 2022 09:34:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151257; bh=G96Dh5WtfTKppnov59BIh9FH3+pya1x2zXt3Qam/+VU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YQqxpVbCXVSYM3Ws8WWAB17KZa63cBysxBOigpMTpECqwZMbdNHVwmf11WDhbcCBs YRTWwrZmcvRGKUkWBWGjdNPZtT3QGheTbp8nsq4/DMua0YA6p9GTAuEBgsI0AI13Xu bGMUHUOGx2SKARHItKY3qNm9IqFmtxFeAdboASzA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiasheng Jiang , Charles Keepax , Mark Brown , Sasha Levin Subject: [PATCH 5.15 350/913] ASoC: wm8350: Handle error for wm8350_register_irq Date: Tue, 5 Apr 2022 09:23:32 +0200 Message-Id: <20220405070350.337418791@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: Jiasheng Jiang [ Upstream commit db0350da8084ad549bca16cc0486c11cc70a1f9b ] As the potential failure of the wm8350_register_irq(), it should be better to check it and return error if fails. Also, use 'free_' in order to avoid the same code. Fixes: a6ba2b2dabb5 ("ASoC: Implement WM8350 headphone jack detection") Signed-off-by: Jiasheng Jiang Acked-by: Charles Keepax Link: https://lore.kernel.org/r/20220304023821.391936-1-jiasheng@iscas.ac.cn Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/wm8350.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index 15d42ce3b21d..41504ce2a682 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c @@ -1537,18 +1537,38 @@ static int wm8350_component_probe(struct snd_soc_component *component) wm8350_clear_bits(wm8350, WM8350_JACK_DETECT, WM8350_JDL_ENA | WM8350_JDR_ENA); - wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, wm8350_hpl_jack_handler, 0, "Left jack detect", priv); - wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, + if (ret != 0) + goto err; + + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, wm8350_hpr_jack_handler, 0, "Right jack detect", priv); - wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICSCD, + if (ret != 0) + goto free_jck_det_l; + + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICSCD, wm8350_mic_handler, 0, "Microphone short", priv); - wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICD, + if (ret != 0) + goto free_jck_det_r; + + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICD, wm8350_mic_handler, 0, "Microphone detect", priv); + if (ret != 0) + goto free_micscd; return 0; + +free_micscd: + wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_MICSCD, priv); +free_jck_det_r: + wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, priv); +free_jck_det_l: + wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, priv); +err: + return ret; } static void wm8350_component_remove(struct snd_soc_component *component) -- 2.34.1