From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E42BEC3A5A3 for ; Tue, 27 Aug 2019 07:59:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B01FE2186A for ; Tue, 27 Aug 2019 07:59:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566892791; bh=K7OO/k/9uTUQTsLSQFVuCi0C18WK/eXM3FKrHoVoJ6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=wtXL5+66A00xMm091oUDa17FUcnx+zjATmC1CNpIV42BIY2PxX5l7LxtFlmfVFAwK iY/bHk2B01IJXnKGb5KTsBW3lEomYccm6iU81wzVhO2QQ5vQXOsXI+pAOcJKb3Otkn qfS8Qs+xvqbHA97Ql7Gc7EdFGFvbelNR6tdZzzR8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730704AbfH0H7u (ORCPT ); Tue, 27 Aug 2019 03:59:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:53750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729841AbfH0H7t (ORCPT ); Tue, 27 Aug 2019 03:59:49 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8BAD121872; Tue, 27 Aug 2019 07:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566892789; bh=K7OO/k/9uTUQTsLSQFVuCi0C18WK/eXM3FKrHoVoJ6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VPY505nQgtNARmb5W5C960sxGFKye30XN4LANTPVM3nNBoIW+evAtUIcfhJMar4Ru qu7bmf6bpvjb6jCivIEPQPMkVMccD3ZQDwNmSh2103g0lk7+5VUiEN7uFmczbmTAvP sJF3aHwHSNVwGRWj9bChTVwnzapcmB/tyhg9UGEo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wen Yang , Kuninori Morimoto , Mark Brown , Sasha Levin Subject: [PATCH 5.2 005/162] ASoC: audio-graph-card: fix an use-after-free in graph_get_dai_id() Date: Tue, 27 Aug 2019 09:48:53 +0200 Message-Id: <20190827072738.370355464@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827072738.093683223@linuxfoundation.org> References: <20190827072738.093683223@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org [ Upstream commit c152f8491a8d9a4b25afd65a86eb5e55e2a8c380 ] After calling of_node_put() on the node variable, it is still being used, which may result in use-after-free. Fix this issue by calling of_node_put() after the last usage. Fixes: a0c426fe1433 ("ASoC: simple-card-utils: check "reg" property on asoc_simple_card_get_dai_id()") Link: https://lore.kernel.org/r/1562743509-30496-5-git-send-email-wen.yang99@zte.com.cn Signed-off-by: Wen Yang Acked-by: Kuninori Morimoto Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/generic/audio-graph-card.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index d5188a179378f..a681ea443fc16 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -63,6 +63,7 @@ static int graph_get_dai_id(struct device_node *ep) struct device_node *endpoint; struct of_endpoint info; int i, id; + u32 *reg; int ret; /* use driver specified DAI ID if exist */ @@ -83,8 +84,9 @@ static int graph_get_dai_id(struct device_node *ep) return info.id; node = of_get_parent(ep); + reg = of_get_property(node, "reg", NULL); of_node_put(node); - if (of_get_property(node, "reg", NULL)) + if (reg) return info.port; } node = of_graph_get_port_parent(ep); -- 2.20.1