Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp906379pxb; Wed, 6 Apr 2022 03:55:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/ZYEkPg/xOPYg4nQH75b/5WBdwbImgCnZqug3nmvktiZ7z9eBVinV2yG1oPUzxZWYRUVR X-Received: by 2002:a17:902:bf07:b0:14f:a3a7:97a0 with SMTP id bi7-20020a170902bf0700b0014fa3a797a0mr8040808plb.105.1649242548832; Wed, 06 Apr 2022 03:55:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649242548; cv=none; d=google.com; s=arc-20160816; b=FD4L5KBEQsNemUA4qeIu8OWrUMSDiy+H6iRfK7UPNQ3BJPwkHK2H0OSfbllnxOoY4S 0ykJ3nHzCbCKaMYO63ZqLBco524IZYIDS/yxVBUnuotdvsuI7bvOScc1FkORKLLftBoG pQQ7AKV+GCkZ3kSz6dgk0mKXzBS9fgsKJOJB3bYwt6AKMIOQZ5cENKXApDijSA/QP0Lw MWl86Mf/9kPo+VkixkWb9X435+h6qTO/nysAJZ4815Ah5Gh8gn340o5kCb8Fz7v28Zv/ nO5Yya7iWZ+1BxbULiN5ey99R/5L2EJyoxeu44FxQT+YC2LYgD0BxlZedN4Pd6jbhc/y RHKg== 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=pbdqchPTiocnR4h17bVYHdz8M2ued0DhyGON9ZidYoM=; b=Wv65DUq5NUy/pCr177+06UYXAgsZJPw16MNWps4KeS19Ux4E37uvvotx91JcwSpGjP F8vdM7dRNQg9aHoKMlEqGjHaBOLs054nfQHyhxtv4uYXdEkNf+XMZ9a5rjl5byMfcQw5 mUwliW6HnsOV4B6l9I4zXDZoZEccFZQLBwe5pRfB2cZOz/BdXVjbitUY4WhTe2xvMoqa ePJXKDkQpbKarUrL73MEbaPBxukqnujYYTCoFloAa0PDnKggoVIDauK3ArSCx+zeRcj8 muViMj5jCHNCMQNrIfgnum3hIGFgOwGcV05ghSejPJO/5CtbAN8A4AEiSEyuqeVZ0A8W Z9bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qB6H0NNs; 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 a12-20020a056a000c8c00b004fa3a8dff62si16514062pfv.25.2022.04.06.03.55.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 03:55:48 -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=qB6H0NNs; 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 CBA615A5FF0; Wed, 6 Apr 2022 02:14:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444274AbiDEX3f (ORCPT + 99 others); Tue, 5 Apr 2022 19:29:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348760AbiDEJsb (ORCPT ); Tue, 5 Apr 2022 05:48:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37CC85C855; Tue, 5 Apr 2022 02:34:56 -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 BE764B81C98; Tue, 5 Apr 2022 09:34:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AD3CC385A3; Tue, 5 Apr 2022 09:34:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151293; bh=LeY3wKEwutDULuXR8eL2wPBlS4V4lm2KrlpDBv17W8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qB6H0NNsyHV4XY7Ewzg/UP15V8ZUB2M5a+B0zOdP5eXHJh2TnX5XdoJODYxY5yEnp 8uH6PAL+wCv3PLGdJX0uACgAA1z8I9hCM5h40VaVD0Ztp7jRFxWGVJ8NhPTkt3TSIK KoTzyEy6S3lTDlaOGEizEf8UwOMbO46xzsbuKU1M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Mark Brown , Sasha Levin Subject: [PATCH 5.15 362/913] ASoC: mxs: Fix error handling in mxs_sgtl5000_probe Date: Tue, 5 Apr 2022 09:23:44 +0200 Message-Id: <20220405070350.696344335@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: Miaoqian Lin [ Upstream commit 6ae0a4d8fec551ec581d620f0eb1fe31f755551c ] This function only calls of_node_put() in the regular path. And it will cause refcount leak in error paths. For example, when codec_np is NULL, saif_np[0] and saif_np[1] are not NULL, it will cause leaks. of_node_put() will check if the node pointer is NULL, so we can call it directly to release the refcount of regular pointers. Fixes: e968194b45c4 ("ASoC: mxs: add device tree support for mxs-sgtl5000") Signed-off-by: Miaoqian Lin Link: https://lore.kernel.org/r/20220308020146.26496-1-linmq006@gmail.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/mxs/mxs-sgtl5000.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/mxs/mxs-sgtl5000.c b/sound/soc/mxs/mxs-sgtl5000.c index a6407f4388de..fb721bc49949 100644 --- a/sound/soc/mxs/mxs-sgtl5000.c +++ b/sound/soc/mxs/mxs-sgtl5000.c @@ -118,6 +118,9 @@ static int mxs_sgtl5000_probe(struct platform_device *pdev) codec_np = of_parse_phandle(np, "audio-codec", 0); if (!saif_np[0] || !saif_np[1] || !codec_np) { dev_err(&pdev->dev, "phandle missing or invalid\n"); + of_node_put(codec_np); + of_node_put(saif_np[0]); + of_node_put(saif_np[1]); return -EINVAL; } -- 2.34.1