Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751610AbdG0X1O (ORCPT ); Thu, 27 Jul 2017 19:27:14 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:34818 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751539AbdG0X1N (ORCPT ); Thu, 27 Jul 2017 19:27:13 -0400 From: Antonio Borneo X-Google-Original-From: Antonio Borneo To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org Cc: Antonio Borneo , linux-kernel@vger.kernel.org, Wei Xu , John Stultz , linux-arm-kernel@lists.infradead.org, Kuninori Morimoto Subject: [PATCH v2 1/3] ASoC: fix use of of_node_put() in of_for_each_phandle() loops Date: Fri, 28 Jul 2017 01:26:10 +0200 Message-Id: <20170727232612.23543-2-antonio.borneo@st.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170727232612.23543-1-antonio.borneo@st.com> References: <20170727232612.23543-1-antonio.borneo@st.com> In-Reply-To: <20170725214952.6491-1-borneo.antonio@gmail.com> References: <20170725214952.6491-1-borneo.antonio@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2126 Lines: 67 From: Antonio Borneo On Hikey target board, enabling CONFIG_OF_DYNAMIC triggers several errors at kernel boot, like the following one OF: ERROR: Bad of_node_put() on /soc/i2s@f7118000/ports/port@0 each followed by stack dump. Each iteration of of_for_each_phandle(){} already provides the needed of_node_put(); adding one more in the body of the loop triggers the error. Fixed by removing the wrong of_node_put(), but adding it when the loop is break out. Tested with kernel v4.13-rc2 with hikey_defconfig taken from https://git.linaro.org/people/john.stultz/android-dev.git branch dev/hikey-mainline-WIP This fixes commit 2692c1c63c29 ("ASoC: add audio-graph-card support"). Signed-off-by: Antonio Borneo --- To: Liam Girdwood To: Mark Brown To: Jaroslav Kysela To: Takashi Iwai To: alsa-devel@alsa-project.org Cc: linux-kernel@vger.kernel.org Cc: Wei Xu Cc: John Stultz Cc: linux-arm-kernel@lists.infradead.org Cc: Kuninori Morimoto --- sound/soc/generic/audio-graph-card.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 105ec3a..20c2029 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -224,9 +224,10 @@ static int asoc_graph_card_parse_of(struct graph_card_data *priv) of_for_each_phandle(&it, rc, node, "dais", NULL, 0) { ret = asoc_graph_card_dai_link_of(it.node, priv, idx++); - of_node_put(it.node); - if (ret < 0) + if (ret < 0) { + of_node_put(it.node); return ret; + } } return asoc_simple_card_parse_card_name(card, NULL); @@ -239,10 +240,8 @@ static int asoc_graph_get_dais_count(struct device *dev) int count = 0; int rc; - of_for_each_phandle(&it, rc, node, "dais", NULL, 0) { + of_for_each_phandle(&it, rc, node, "dais", NULL, 0) count++; - of_node_put(it.node); - } return count; } -- 1.9.1