Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp725448pxb; Tue, 5 Apr 2022 20:29:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRQUH44VjCrnrJGnvt6zPOkPscfKYYNcnzQjNUxjZpGbsGXNirdgPMuDBGecQAD18BNmWL X-Received: by 2002:a17:90a:8c8e:b0:1c9:c81d:9e13 with SMTP id b14-20020a17090a8c8e00b001c9c81d9e13mr7515880pjo.123.1649215795563; Tue, 05 Apr 2022 20:29:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649215795; cv=none; d=google.com; s=arc-20160816; b=v5fhBpmg3zZnrMja3g7Dy7nUlgsxEiW2CBJ7yWtaaN2HtCJRp+r+Gjuxs/aMmuIURT 74B5uoJrkTX3b5sGH4Y7x7eNNrvtrxlUQWBRwkoW3zqpJECFT5uueOi+prk80NG0k3Xg 7Xh1JHSUOIP+/QTTcYp1S0G8JddgFdM5BBm3mN8vCaiUWKtM0+UmVYktUUvkhmyVJTxU jDIUCBag8hmJIPid9n5ZsxUTRDJoe+DqW4pQePzsvcqfwcnv3NJEuGPt0s2Zj3/pnebn 3QXJUV887TNtGKuCxB+DKiaUpGAU2mIKbsbVBLWxkNLmw8AqCWOJ5k+1VWt3jOjheFcx Ot+Q== 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=gr48WzwY+xTcSQYjNgZksscamO0Zi76Vw/DA8ikKeXGCIJfxzQhSpSEmF98FZv/6Vd wMw7p42ICnhSOxDPcFTOK342QR1UZtn2EXff+MBilJMmMszMGUkxf5teE6ctZhQun3T+ 1uaQZirCSH4lzWYGKr7N7fcY0lesw6b3jdOTzk+VPkdjszYJD6W0HK4y1IzHLdu3omko NZp8X59xRM+xxgCDWx/Am8O6iFS7AWPjmc441t6YULRC6XgobMyD3xjjLwKFANpXj8xf kLAIldXBCoyB4PIYNnuNOeigWecYYb8NnOkC7TQ4GEpYTrPO+5/D1iPuCWHgQPJ2EwFA 7fHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pmvpv8NC; 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 z7-20020a170903018700b0015408cd595asi15871933plg.27.2022.04.05.20.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 20:29:55 -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=pmvpv8NC; 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 6C422C6835; Tue, 5 Apr 2022 20:01:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382782AbiDEMQz (ORCPT + 99 others); Tue, 5 Apr 2022 08:16:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244967AbiDEIww (ORCPT ); Tue, 5 Apr 2022 04:52:52 -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 447691CB2B; Tue, 5 Apr 2022 01:48:11 -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 D43BC61511; Tue, 5 Apr 2022 08:48:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1589C385A1; Tue, 5 Apr 2022 08:48:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649148490; bh=G96Dh5WtfTKppnov59BIh9FH3+pya1x2zXt3Qam/+VU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pmvpv8NCc4kCeNcsrxybV1hHUeK88fpxdQrUUDKgSVaJ6DrYXvJ6LEe+nM6GCwWxD 3cUFICWB2nkoN/P8Ush2iBIOj7xivZoil/WndQrDtCkfUCEJJ8MRnioWsmw8S+W70g cu2LUb9MofxCoe00xd0+6OfeNZjTx/mvb4ipNh34= 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.16 0373/1017] ASoC: wm8350: Handle error for wm8350_register_irq Date: Tue, 5 Apr 2022 09:21:26 +0200 Message-Id: <20220405070405.357775848@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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