From patchwork Sat Nov 24 14:52:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 10696551 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D472E16B1 for ; Sat, 24 Nov 2018 14:52:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA7C62A24A for ; Sat, 24 Nov 2018 14:52:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A82E2A272; Sat, 24 Nov 2018 14:52:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 42C882A24A for ; Sat, 24 Nov 2018 14:52:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=U1wGng5eiB1Xo0Zfu0ontLuj0r+ozzT2BEMsq3CkA78=; b=eGq KRidyJD02LnJ/vivQPF/4w9FsK2oOxQlkaVAKmO3GzUQcqk3Tp6mT/2X49u3mSbSATjLPD8u+iTd/ 6Pw/IlnMyIYA3f1Krn5K5T/iokmrUSeZOgcvdAa3wIjwOZ2CJInup7VbTYGZoIbetAuHWrAmuIOEd ZgAbkqEN8JzAplp1myCCHufL0V1DYSamSQSW91RUjJkHkS7aQGEkcEGTxbYkNMZqJrDKOT7kyJyaS qgilpzHlcio4Fu8NeDoCH8gnsNc6RN+Zannji04cDZ8vNbLjCvo2YWTmqdlPPDHoTjmnrrdb2iTQg LPVZLlSKiOEI8pDd5tox3ejfHNSGcKQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQZId-0006oy-4U; Sat, 24 Nov 2018 14:52:47 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQZIZ-0006o9-SY for linux-arm-kernel@lists.infradead.org; Sat, 24 Nov 2018 14:52:45 +0000 Received: by mail-pf1-x442.google.com with SMTP id q1so4541472pfi.5 for ; Sat, 24 Nov 2018 06:52:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=dTUZi6rTdpQ1F5N9zxpSCRC4SoFmApcq+FhlMANmNOQ=; b=B5P5HdVC5at+pZRIZHGOLNzhJEQpK0IMbfJQb9s/KtmFyTXT8rhVCyXjjkx3SFKaxz ZUuC2OHqTI0t8ioak5E/VX9KmCmVOiVuMpv5SDYtNjXcmwjqqQJanAvwoj8UG+JxeVJU NQnrfn/0jUzHnM6ulEUvmokcQEwjJsqXRCVfl2plbNU0PDqyHBOZQPfwJLXlMr46/V4n xOcpOadmTd3IH3endb2lTQh2wNO3VuSgW0iafRvbbxH16MrJJIxSiquuyEBCBPD8+kfA Z2Gv13hwkADoqa590GGMprXEm+R55xKSlRXorDrwmbsStTdbSS2KSOPHluaEf3sXX2qW yVrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=dTUZi6rTdpQ1F5N9zxpSCRC4SoFmApcq+FhlMANmNOQ=; b=ubXBY3ZGFOxutyMk7njvgEJSo4DSJehAXcDwMnTmxQw5NH/wnhSBgCQaCkzsVfjKoh WDJKEvrZngrDjWYbf7nK0gTPXPkZ79nH212OfapTFRCpB8meCdqNK3m8n5RO0Hs5lbzy 3SAlX01oP3bxaCysxcj4IU2u05W7MEB8cRVjVWbrKycjol3SJW9wXYFRgIy2cc40bLI1 jOLdzV8BC3yKYCjvIKYZAff9NUb4WsaJzYFc0gw/+jyXyXMl//mSG2gt2H4wlJwfdF24 Fah1Tlm07g9/VZfL9Q2IBr+PmNalHjt8j6DL0HNlLkYUQJNVX+9UWLworznVGj8DXWN6 3bsA== X-Gm-Message-State: AA+aEWb0YGbgEUq1cGxIu5AeV4LgcM5Ryzgc//JoZrNl1wufj5WzPrOW McH/q5Uz/bTkflpePKMq6fY= X-Google-Smtp-Source: AFSGD/Wbf7esdOVICA07BmEF954p5ECitMyLPwor+yW+W7dwl/5hOkzMYw7pGZOx7cd3Po/cuHnDKg== X-Received: by 2002:a63:d301:: with SMTP id b1mr18206246pgg.61.1543071151621; Sat, 24 Nov 2018 06:52:31 -0800 (PST) Received: from localhost (68.168.130.77.16clouds.com. [68.168.130.77]) by smtp.gmail.com with ESMTPSA id h7sm62476146pfa.105.2018.11.24.06.52.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 24 Nov 2018 06:52:30 -0800 (PST) From: Yangtao Li To: computersforpeace@gmail.com, gregory.0xf0@gmail.com, f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, treding@nvidia.com, olof@lixom.net, arnd@arndb.de Subject: [PATCH v2] soc: bcm: brcmstb: Don't leak device tree node reference Date: Sat, 24 Nov 2018 09:52:23 -0500 Message-Id: <20181124145223.29208-1-tiny.windzz@gmail.com> X-Mailer: git-send-email 2.17.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181124_065243_964714_642A4354 X-CRM114-Status: GOOD ( 11.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yangtao Li , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP of_find_node_by_path() acquires a reference to the node returned by it and that reference needs to be dropped by its caller. soc_is_brcmstb() doesn't do that, so fix it. [treding: slightly rewrite to avoid inline comparison] Signed-off-by: Yangtao Li --- Changes in v2: -update changelog -slightly rewrite to avoid inline comparison --- drivers/soc/bcm/brcmstb/common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/soc/bcm/brcmstb/common.c b/drivers/soc/bcm/brcmstb/common.c index 14185451901d..bf9123f727e8 100644 --- a/drivers/soc/bcm/brcmstb/common.c +++ b/drivers/soc/bcm/brcmstb/common.c @@ -31,13 +31,17 @@ static const struct of_device_id brcmstb_machine_match[] = { bool soc_is_brcmstb(void) { + const struct of_device_id *match; struct device_node *root; root = of_find_node_by_path("/"); if (!root) return false; - return of_match_node(brcmstb_machine_match, root) != NULL; + match = of_match_node(brcmstb_machine_match, root); + of_node_put(root); + + return match != NULL; } u32 brcmstb_get_family_id(void)