Received: by 10.223.176.5 with SMTP id f5csp2830499wra; Mon, 5 Feb 2018 10:33:54 -0800 (PST) X-Google-Smtp-Source: AH8x2266jsCQOAAqDSvxIAHyLgSlVGVQFBR0HYj0OYjZl1rp+OsPdYFpps3ao9gOHRaEsNivDDaF X-Received: by 10.99.146.3 with SMTP id o3mr39679053pgd.309.1517855634111; Mon, 05 Feb 2018 10:33:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517855634; cv=none; d=google.com; s=arc-20160816; b=Kv6SOJaMx9o4MzVZWoqfNoYSnkc647BfC/6ev9kBnbaEu2cFuDr2LcEs3zClS4Nqay jomRMrgm9AR/F2rbrifeHctmYQ0pMV6beT9hFgvT11aPk7x3RTd37U6MF+Ais1QQxt7p XinP6076NC7cqgmgUeGmseAPIQGlTfFLkvXEr0QR9uOtHaUKsixX/0HZgq3Ow4QViCtr hZomKAb6npN47k1456Kt2Jde5SimJirOWc33cC281PsYd0l3kk4cohYol8yCPZMxWIAt 7I7x2qSzZ3uPKp6oRD204FoATLCVOLzMTgn/dp+PJzq+l94iMNF9A+skHDxHs7qcafxt WqTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=9y+zbcBY7nXBwxKiM6EzwS751u1S59xjvSnhMSkXMrE=; b=OfqD3FJysyW9dum1BESu3IiyZs3kKdvlYwrjLZVK2QvMp/A3LnNu6UcCVChNbjO6UO WwAJ71V2EF5CJ66qo8Nmm1O69W+bImXeA8iuWXS+MX+BQrQP45mU9b/xifu4OHFv34xb mLHzuNKA0LAZIlRCfL/D/W/On0T5wENAlI7+1dQXkDayFUhmfmR11FWncAGiL5p35p1q MILDxgGe0+eJ4C5J15l27C3DaUYVmMGPKG1pFAiE4mTantn/61LgYtyZ/qHBiCA2cC+q Eb6nfyQGhlSLrF0Y0kNiu/suu79/UWZ9GC/FS0Ch3c2YG9f5uzDHIvi/wFufqs/A3uDP 6MTA== 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 t4-v6si7137937plb.415.2018.02.05.10.33.39; Mon, 05 Feb 2018 10:33:54 -0800 (PST) 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 S1754033AbeBEScY (ORCPT + 99 others); Mon, 5 Feb 2018 13:32:24 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:53090 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753842AbeBES0B (ORCPT ); Mon, 5 Feb 2018 13:26:01 -0500 Received: from localhost (unknown [104.132.1.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 911E31156; Mon, 5 Feb 2018 18:25:46 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Abbott , Alan Tull Subject: [PATCH 4.15 60/60] fpga: region: release of_parse_phandle nodes after use Date: Mon, 5 Feb 2018 10:23:33 -0800 Message-Id: <20180205182217.215908210@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180205182213.902626065@linuxfoundation.org> References: <20180205182213.902626065@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ian Abbott commit 0f5eb1545907edeea7672a9c1652c4231150ff22 upstream. Both fpga_region_get_manager() and fpga_region_get_bridges() call of_parse_phandle(), but nothing calls of_node_put() on the returned struct device_node pointers. Make sure to do that to stop their reference counters getting out of whack. Fixes: 0fa20cdfcc1f ("fpga: fpga-region: device tree control for FPGA") Signed-off-by: Ian Abbott Signed-off-by: Alan Tull Signed-off-by: Greg Kroah-Hartman --- drivers/fpga/fpga-region.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) --- a/drivers/fpga/fpga-region.c +++ b/drivers/fpga/fpga-region.c @@ -147,6 +147,7 @@ static struct fpga_manager *fpga_region_ mgr_node = of_parse_phandle(np, "fpga-mgr", 0); if (mgr_node) { mgr = of_fpga_mgr_get(mgr_node); + of_node_put(mgr_node); of_node_put(np); return mgr; } @@ -192,10 +193,13 @@ static int fpga_region_get_bridges(struc parent_br = region_np->parent; /* If overlay has a list of bridges, use it. */ - if (of_parse_phandle(overlay, "fpga-bridges", 0)) + br = of_parse_phandle(overlay, "fpga-bridges", 0); + if (br) { + of_node_put(br); np = overlay; - else + } else { np = region_np; + } for (i = 0; ; i++) { br = of_parse_phandle(np, "fpga-bridges", i); @@ -203,12 +207,15 @@ static int fpga_region_get_bridges(struc break; /* If parent bridge is in list, skip it. */ - if (br == parent_br) + if (br == parent_br) { + of_node_put(br); continue; + } /* If node is a bridge, get it and add to list */ ret = fpga_bridge_get_to_list(br, region->info, ®ion->bridge_list); + of_node_put(br); /* If any of the bridges are in use, give up */ if (ret == -EBUSY) {