From patchwork Tue Mar 8 02:01:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaoqian Lin X-Patchwork-Id: 549334 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0CE68C433F5 for ; Tue, 8 Mar 2022 02:02:55 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C4DB5179B; Tue, 8 Mar 2022 03:02:02 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C4DB5179B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1646704972; bh=qLavn0mAozPLMFQGxm3aE+Q2bbx6PNXSYdslMjXNY5M=; h=From:To:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=dCSeQUGODrXymruuZifDG1zoVK4GTDqZe1fLY5A/FTQdyeasYSsXeO5NFA5ay7ovm 2lCl4KDbh0SXDC2HiHht3TJzh7OM85+ttV+wA+ZxaNusf588Qa5e0nEn02uAT6Qi3/ k2pb+8f3qIl36p9hzZPdFRCia27J6c8tdBFAxoTs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3F263F80132; Tue, 8 Mar 2022 03:02:02 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id AB4B7F8013F; Tue, 8 Mar 2022 03:02:00 +0100 (CET) Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3CF34F800D1 for ; Tue, 8 Mar 2022 03:01:54 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3CF34F800D1 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WPJQz9gU" Received: by mail-pg1-x529.google.com with SMTP id 27so15102542pgk.10 for ; Mon, 07 Mar 2022 18:01:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id; bh=/vVnL9eYRSzGukw8SFc4KUz6RxUiiMNRCtt3A6IgWHI=; b=WPJQz9gUASBXedyL88smBZOyRA9JuY+a6vfbE+eUe337T1Tdam2Tf3OdpOD35A7R70 n4AZomhDj5LMij9G0rEak9DF6iZxzULyMTsFYg491ifyShip8mRnyv9lhVKxiuoAE3+w B1ahPQ2lO+Jb7T7wpPIbsWkHqTnRpEIcpnkTegl7jdwBLN/EhPOqAajySUM41nn4Eoq5 3kOr3qn7HUpednBBnSY+H672xEHFyQK4x7Kk205sEjbyxfxQZO4EhM7QlIIFBXE6gVmK T1rRrXRKxl9glJm7PIf4pkFV+AK/lQ7JP+fTPNh87KLBSdJmKwu7tQ+tn5Sh4mnUfwlF LkLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id; bh=/vVnL9eYRSzGukw8SFc4KUz6RxUiiMNRCtt3A6IgWHI=; b=JwLhg/LXW1C5WJFhhJhepMrNNi+F7ODUX7x5wV+SXbgKE17jPzLVgTDzPAoZ2jWcPl Q3UuFCdZKnIbuRZ+ygKtIXOGo8eQPoK1SGTJyJNzk5yvvMcnt2M04vM9VLM81xp9fbSx qJM1O7Sb98JLUEfLTpEi1yRL60OUt+Raw9CHmzweNdtgPjFmPDwV7nBG8irpS1Uf5HTu N4cmYOb1KxNuDIIABgi0IvpGcpoHULMcQ4G8QWhOVTdKpz4Xkd8AnlyvoUMbwmedre28 lTpM1KhgG6aN/q5kMRoXWm5Rvq6lHIBfF50FnlOY67RUqwNMjVFt10BJEXrQc0OMR85Q uM4g== X-Gm-Message-State: AOAM533j7jLKggMFyE1uvLsNova19HCkbJ6oEaGKwfqx36QoWO2PMnNN 3kgtU31XwDlbmtdfJB9KZx0= X-Google-Smtp-Source: ABdhPJxCExbpTHk8a9vWWJJ96DNwpeeHzcqKYTbVm6C0ubr8FBGHGZ33z0smAzSg2JP/ol4UAJAeEQ== X-Received: by 2002:a63:84c1:0:b0:380:64fd:a2d4 with SMTP id k184-20020a6384c1000000b0038064fda2d4mr4690598pgd.51.1646704912369; Mon, 07 Mar 2022 18:01:52 -0800 (PST) Received: from localhost.localdomain ([159.226.95.43]) by smtp.googlemail.com with ESMTPSA id pc17-20020a17090b3b9100b001bf88fe5edcsm393672pjb.9.2022.03.07.18.01.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 18:01:52 -0800 (PST) From: Miaoqian Lin To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Kuninori Morimoto , Miaoqian Lin , alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] ASoC: mxs: Fix error handling in mxs_sgtl5000_probe Date: Tue, 8 Mar 2022 02:01:44 +0000 Message-Id: <20220308020146.26496-1-linmq006@gmail.com> X-Mailer: git-send-email 2.17.1 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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 --- 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 2412dc7e65d4..746f40938675 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; }