Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp699804pxb; Tue, 5 Apr 2022 19:19:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaNIh1C4F5LqOMZEn4zZEtnEo8/qoCRn2BDAnQ+Af4N59teYsR0iKOL951JM3KpoeKjH7w X-Received: by 2002:a17:902:c105:b0:154:81e0:529d with SMTP id 5-20020a170902c10500b0015481e0529dmr6435854pli.1.1649211557979; Tue, 05 Apr 2022 19:19:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649211557; cv=none; d=google.com; s=arc-20160816; b=G8lp08qT993TmW5RG6vaVBYt+YbGSU0QqGPEWOa9TnfgyopkyQ4Wzb2SeauZ58k3VA pBhpPLJGxowulkr3oCwvdoJudVuKZfHQxUnlbnd4uLQPwH4Uj6zNmokW/GDm01HHup0+ oavxkXm3dvKqWYpL2QIn91buP4zLySaQA7hfavHcp5H7zmpHu7OtGBal0ypKBaQUTqwy tGFoq5E1YQrQVdt3EwTJvaouV6CC014YbFHLbhf7qGEjGmB12kNVIlLwmqfbvEXDETeK 125eKPf5uK9yV/31jFZweQUxCjwCObC6wg06P9Bouz91anMZ0GQQ2aFwPO11bRd1txzI 1LHA== 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=aKzYfHqbB3dMMfAlC+7ei5asG8om41vbRNjUMrdnUgRID6aXe3L0E9jp0gJT3ZwtRn pMqg5DOm+f8wsa0lyFARW6egQFeB+jeEj/G24t84Ze6+Bkl+KtZxzhncHsy3Cceey4JG 5iygWQ2u4b7Jqji7jSvPkWnA/iAkZSyBhLHA4LW2xoZq9DSgGJnD072Iq/rfh/Mef97z FoFEfxyXN9aPuSq8DblVvMHX9IhRh8RE3JijjUDY/Y47FMIMLBPTaTcKe4LsTXDmv6Vq aa1NdREPDPmtvpjw/3UjOTKZeR4agp5MUAQsuk7YPgViSBWSYYQxX5JvFOEn+DO4oJMW fNzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wkK0ruDj; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c7-20020a170903234700b00153bc4c8388si15607830plh.499.2022.04.05.19.19.01; Tue, 05 Apr 2022 19:19:17 -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=wkK0ruDj; 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 S1376552AbiDEL5O (ORCPT + 99 others); Tue, 5 Apr 2022 07:57:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245000AbiDEIxA (ORCPT ); Tue, 5 Apr 2022 04:53:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD713DF61; Tue, 5 Apr 2022 01:49:02 -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 76E97B81A32; Tue, 5 Apr 2022 08:49:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CADF7C385A1; Tue, 5 Apr 2022 08:48:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649148540; bh=LeY3wKEwutDULuXR8eL2wPBlS4V4lm2KrlpDBv17W8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wkK0ruDjJKrn0OpnsU9onHeSFRb0tab//jdop/JbwpN5j2yxgK1crvcEC+qlY7Oxq mmaIkps6c0ZAzOQWromsnBap59ncdHNwgRYbp9zNRDhDZ027so2zCn4nyJ4krfErGT d1N1Vy2VFQ3SVXhRbsZJBSv0933gtXWXysY+LWng= 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.16 0385/1017] ASoC: mxs: Fix error handling in mxs_sgtl5000_probe Date: Tue, 5 Apr 2022 09:21:38 +0200 Message-Id: <20220405070405.713882548@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=-7.1 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,T_SCC_BODY_TEXT_LINE 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 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