Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1059716imm; Fri, 29 Jun 2018 10:39:55 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeY8+FxDPfoo1x70IivE6+WGm3jIqr1itd7HMjOgTneUvadJJQhsNwnPNkKJTaNgm+7JF3R X-Received: by 2002:a62:968f:: with SMTP id s15-v6mr15402655pfk.191.1530293995416; Fri, 29 Jun 2018 10:39:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530293995; cv=none; d=google.com; s=arc-20160816; b=ku3ceezSo9aII3CbFIZfaJqmenWdZtHoShkckcbB3AtAvorPwia7Idy7akBfNmsjpC fFXp4unGpwTKPX+gQvuTUAV76Y4QhSxglJBtCEIgmy6JhpTN4o2MDNLzAh6ooC4Gk84H Kh++5ClgIiDx95ha7Ol/VHi6xFlxuLvTAqpCJhiAInE881SJgrE5Xv+G+rv6B75mFyal KgiZhOosbdJrPJw4R2ccGIjWtHXpnaSPhQ9wvbrMxB59ZymJz2y9oMvgJfwcVF/2L876 ZM8iGI7QeH72C8cfzPuv59fS+pzC/2rPiqloBp6uCSJr/hEcTelW4QTwfOOiHGryTMW4 +akA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=U+tlafU+npEw82OaDl0/qfSGapbBzVNhuHvklRlROVI=; b=tegVK5hf9xNleBLBnj8mxxVo7lH4rUB3om6tXJZFz8Bjs7epSi+MmUKYD8JGDPz1X+ s1h5ws/K2K9zph51RQpiNXqsQIIoIGaRe7QYWcNn3j500BvQssRQqd+FkagGDwOFM4wn paHBZBcV5EmZ1QwQWC9OyjZ7+sHLETaM08LI9XPDDoxMEOkAwLr/RmQjWgtjkQrkxJ3w KX89Fglq5FQaWczCV5G1c6V2jZO+JgKVMwJL6++vixHGKRkyadUqQZkGXF0wJmcg5UP9 T9l7Fh/9Mvnr4UphEJMe/dl9NMg7yP9ww4rkLpX84LrW//4Ss7RW/IEyLzhbM40DNP3y g52Q== ARC-Authentication-Results: i=1; mx.google.com; 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 i6-v6si8912985pgt.470.2018.06.29.10.39.41; Fri, 29 Jun 2018 10:39:55 -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; 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 S937134AbeF2RL3 (ORCPT + 99 others); Fri, 29 Jun 2018 13:11:29 -0400 Received: from www.osadl.org ([62.245.132.105]:51542 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932446AbeF2RL2 (ORCPT ); Fri, 29 Jun 2018 13:11:28 -0400 Received: from debian01.hofrr.at (178.115.242.59.static.drei.at [178.115.242.59] (may be forged)) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id w5TH8Dx4001970; Fri, 29 Jun 2018 19:08:13 +0200 From: Nicholas Mc Guire To: Johannes Berg Cc: Jaroslav Kysela , Takashi Iwai , linuxppc-dev@lists.ozlabs.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH] ALSA: snd-aoa: add of_node_put() in error path Date: Fri, 29 Jun 2018 19:07:42 +0200 Message-Id: <1530292062-31567-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 X-Spam-Status: No, score=-1.9 required=6.0 tests=BAYES_00 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on www.osadl.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Both calls to of_find_node_by_name() and of_get_next_child() return a node pointer with refcount incremented thus it must be explicidly decremented here after the last usage. As we are assured to have a refcounted np either from the initial of_find_node_by_name(NULL, name); or from the of_get_next_child(gpio, np) in the while loop if we reached the error code path below, an x of_node_put(np) is needed. Signed-off-by: Nicholas Mc Guire Fixes: commit f3d9478b2ce4 ("[ALSA] snd-aoa: add snd-aoa") --- Problem located by an experimental coccinelle script Patch was compiletested with: ppc64_defconfig (implies CONFIG_SND_AOA=m) Patch is against 4.18-rc2 (localversion-next is next-20180629) sound/aoa/core/gpio-feature.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/aoa/core/gpio-feature.c b/sound/aoa/core/gpio-feature.c index 7196008..6555742 100644 --- a/sound/aoa/core/gpio-feature.c +++ b/sound/aoa/core/gpio-feature.c @@ -88,8 +88,10 @@ static struct device_node *get_gpio(char *name, } reg = of_get_property(np, "reg", NULL); - if (!reg) + if (!reg) { + of_node_put(np); return NULL; + } *gpioptr = *reg; -- 2.1.4