Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9982445ybi; Wed, 24 Jul 2019 13:30:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqxokjmt17qn2rplO8q7HXGrJ8/NpUq+qrrmtTh9abRPGn23ZpcBoDgJNVrFB33R1WW/Ize3 X-Received: by 2002:a17:90a:1c1:: with SMTP id 1mr89548405pjd.72.1564000234599; Wed, 24 Jul 2019 13:30:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564000234; cv=none; d=google.com; s=arc-20160816; b=UOMBS7t0n63j1PCzJal2rAOnox5Yt+WLwA9HJwpArMyRcUcOsBT8izGeGcfHbaakvS BN6VmadAiRyzvl7W2WFvltT6xDMkZq/ksbWk1jauQLkwRLLklR3MyrIMJRwfdtutNnvc hoRbpJn0QDJREfWg/7h3v9ouNk22z+GZUUkhO2CitnQNR5ys9uM1DYm+g/zRTt7JGR/n EO5ostaqEm8+3Ryaegn+dcT6jCYvCQkgdxUvZbycZvan0/Ergqub/NK4OPoSEfPsMl2n MrcW6nFgXzIkxvph3M693wV0+GZNqc1cHFZEDPmYOusWqXjXZmKcyP4wI4MkZ9+gqMXH U6dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cBnFOiT+yqKfsdTsHXrvBlq1diZ7Ja/yJ2CK4lV/yjU=; b=gtOWQb17j7kiNOh/IKuZNTv0nGPAoFNAlswlNqwLF6hwtPlw9VkHgXTlLV08i3dvnq BKCnvxpRshCXMM3P9oKOHq8QG0v77mk9I1HWVq8XHHQXgooIbkatCuIvhpMycUJ1gK6f SMkFrCOIC6E0Pvc7gK6JANZcyXvznra1Qea6V/WabVh3w9VIli6nhToCJUGtwjhcSVx2 ayi+oXIsppqVnkcoRZPKjneURG4Qqp3+4t14Fb29YZiNojvpoIXkQU2qfYd+rm5pILti dsixGadDdiz01FUS+GEZTyScoxiFMVXW0x9fPSRuDU8NLx1S/VFljYLeI5tw7fLBs/kC DCYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bpF0PtuI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w188si15362729pfd.283.2019.07.24.13.30.19; Wed, 24 Jul 2019 13:30:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bpF0PtuI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726696AbfGXTd3 (ORCPT + 99 others); Wed, 24 Jul 2019 15:33:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:55278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387800AbfGXTd1 (ORCPT ); Wed, 24 Jul 2019 15:33:27 -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 0374C22BE9; Wed, 24 Jul 2019 19:33:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996806; bh=Y0hnk/U6RFGoIIQo69U5gHJnUQyGoGrK5t/PGcnZzQk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bpF0PtuIfZqpDkYAel/WwzqthMhTrlulcm0BGGJa4bD76bppLtytrV0CYHblKQjqF zolwY6FLVdLiqC0vlOGJdqPL5OWFp7EgvyUsMBA2MVt1F1EUaxwtNlA5PumxsrqMA/ ta/tFkzj30Cek7usFcHFZinkueqtjvKqP0qhoej4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wen Yang , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Kuninori Morimoto , alsa-devel@alsa-project.org, Sasha Levin Subject: [PATCH 5.2 224/413] ASoC: audio-graph-card: fix use-after-free in graph_for_each_link Date: Wed, 24 Jul 2019 21:18:35 +0200 Message-Id: <20190724191750.933840751@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 1bcc1fd64e4dd903f4d868a9e053986e3b102713 ] After calling of_node_put() on the codec_ep and codec_port variables, they are still being used, which may result in use-after-free. We fix this issue by calling of_node_put() after the last usage. Fixes: fce9b90c1ab7 ("ASoC: audio-graph-card: cleanup DAI link loop method - step2") Signed-off-by: Wen Yang Cc: Liam Girdwood Cc: Mark Brown Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: Kuninori Morimoto Cc: alsa-devel@alsa-project.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/1562229530-8121-1-git-send-email-wen.yang99@zte.com.cn Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/generic/audio-graph-card.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index ec7e673ba475..70ed28d97d49 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -435,9 +435,6 @@ static int graph_for_each_link(struct asoc_simple_priv *priv, codec_ep = of_graph_get_remote_endpoint(cpu_ep); codec_port = of_get_parent(codec_ep); - of_node_put(codec_ep); - of_node_put(codec_port); - /* get convert-xxx property */ memset(&adata, 0, sizeof(adata)); graph_parse_convert(dev, codec_ep, &adata); @@ -457,6 +454,9 @@ static int graph_for_each_link(struct asoc_simple_priv *priv, else ret = func_noml(priv, cpu_ep, codec_ep, li); + of_node_put(codec_ep); + of_node_put(codec_port); + if (ret < 0) return ret; -- 2.20.1