From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39CB1C04EBD for ; Tue, 16 Oct 2018 02:47:23 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AC218208E4 for ; Tue, 16 Oct 2018 02:47:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PfCb+n7S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AC218208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42Z08S46cDzF1Hr for ; Tue, 16 Oct 2018 13:47:20 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PfCb+n7S"; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::444; helo=mail-pf1-x444.google.com; envelope-from=frowand.list@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PfCb+n7S"; dkim-atps=neutral Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42Yzz744MJzF3Vt for ; Tue, 16 Oct 2018 13:39:15 +1100 (AEDT) Received: by mail-pf1-x444.google.com with SMTP id u12-v6so10628917pfn.12 for ; Mon, 15 Oct 2018 19:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6jwtNAKUA0bImQ+OzjBieSYaakSLUGtiTllRPSG9WlA=; b=PfCb+n7SPWybcVF+ENhWNNQeAbHWxVp087paajc+P1UcxIsL61AfFbqKZM4/DCZ8Wg pcXNv9h/+ZwiuJg19t/alKps71XwafwL73++Ow1sDcb5wDb7/8j0mjd//KTaQFhm7Qfa By/pXBWPPIg3tX1irLch02z+VoxagT/vIvSCl0a3Gl6HVk1MqA69glokpvt142LJk9nC etFpdLy37aJWqy4mX9OBUTlFjQ2doXsHkVqjaftykg5BTYQP4CmjFiEbUGHNZSYCGEav kf0136rNDXgf6Tbusj2xY/Sh9JPhyYMkkcy7XdP4vIf47orpIS+NXXbcV8lNgTOUZoIp K2jg== 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:in-reply-to :references; bh=6jwtNAKUA0bImQ+OzjBieSYaakSLUGtiTllRPSG9WlA=; b=au/qt3G9HY9f6FTYVJwW72yeTXZuEAoigUtXdCtXzbQbiFOxslV88PFCZ3jgUTQxrA Sg8S3Ihl7bnQpSvyXAO0WWBjQK4Cn3AcZCwbIQyPah4bv31lfn5E6lF9qYeBLSlM7H/J QBOhWjTVlePHdH/nGzl+6w1YGY+jC0xDN4XqwcGWMrsTt/VLhKxXtecI8PeP9FBxmRmf NuuqVUrLtOkveNhnSE+QUED3pvJSVwBz1SDqZyv+63dcPDp/MdB17f4jWZ66YfRtKOR/ zE84D/8i/5JEiPy5jmZOBSM5f/hPgH3IFKvQ5OfsVTm9B1XgOIx3Vy9nd+0VBRYLQwQQ 5Pkw== X-Gm-Message-State: ABuFfoiEZyl4NnCNi5WxGOabb31BueTmyx5xy1sn7Fz9InB+JMXGPO/V LxhNyr0tTob8i1vxroipBhA= X-Google-Smtp-Source: ACcGV60a93Uk9Vf9y1ELaanVjQ0ckmAPo3W6mw6/cN+T00j9hArFUmjSH2qR7XY3dPjW1EGopBzEPg== X-Received: by 2002:a62:fc13:: with SMTP id e19-v6mr20352542pfh.101.1539657553847; Mon, 15 Oct 2018 19:39:13 -0700 (PDT) Received: from localhost.localdomain (c-24-6-192-50.hsd1.ca.comcast.net. [24.6.192.50]) by smtp.gmail.com with ESMTPSA id u79-v6sm18620287pfd.117.2018.10.15.19.39.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Oct 2018 19:39:13 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v4 02/18] of: overlay: add missing of_node_put() after add new node to changeset Date: Mon, 15 Oct 2018 19:37:22 -0700 Message-Id: <1539657458-24401-3-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539657458-24401-1-git-send-email-frowand.list@gmail.com> References: <1539657458-24401-1-git-send-email-frowand.list@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Frank Rowand The refcount of a newly added overlay node decrements to one (instead of zero) when the overlay changeset is destroyed. This change will cause the final decrement be to zero. After applying this patch, new validation warnings will be reported from the devicetree unittest during boot due to a pre-existing devicetree bug. The warnings will be similar to: OF: ERROR: memory leak of_node_release() overlay node /testcase-data/overlay-node/test-bus/test-unittest4 before free overlay changeset This pre-existing devicetree bug will also trigger a WARN_ONCE() from refcount_sub_and_test_checked() when an overlay changeset is destroyed without having first been applied. This scenario occurs when an error in the overlay is detected during the overlay changeset creation: WARNING: CPU: 0 PID: 1 at lib/refcount.c:187 refcount_sub_and_test_checked+0xa8/0xbc refcount_t: underflow; use-after-free. (unwind_backtrace) from (show_stack+0x10/0x14) (show_stack) from (dump_stack+0x6c/0x8c) (dump_stack) from (__warn+0xdc/0x104) (__warn) from (warn_slowpath_fmt+0x44/0x6c) (warn_slowpath_fmt) from (refcount_sub_and_test_checked+0xa8/0xbc) (refcount_sub_and_test_checked) from (kobject_put+0x24/0x208) (kobject_put) from (of_changeset_destroy+0x2c/0xb4) (of_changeset_destroy) from (free_overlay_changeset+0x1c/0x9c) (free_overlay_changeset) from (of_overlay_remove+0x284/0x2cc) (of_overlay_remove) from (of_unittest_apply_revert_overlay_check.constprop.4+0xf8/0x1e8) (of_unittest_apply_revert_overlay_check.constprop.4) from (of_unittest_overlay+0x960/0xed8) (of_unittest_overlay) from (of_unittest+0x1cc4/0x2138) (of_unittest) from (do_one_initcall+0x4c/0x28c) (do_one_initcall) from (kernel_init_freeable+0x29c/0x378) (kernel_init_freeable) from (kernel_init+0x8/0x110) (kernel_init) from (ret_from_fork+0x14/0x2c) Signed-off-by: Frank Rowand --- drivers/of/overlay.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 1176cb4b6e4e..32cfee68f2e3 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -379,7 +379,9 @@ static int add_changeset_node(struct overlay_changeset *ovcs, if (ret) return ret; - return build_changeset_next_level(ovcs, tchild, node); + ret = build_changeset_next_level(ovcs, tchild, node); + of_node_put(tchild); + return ret; } if (node->phandle && tchild->phandle) -- Frank Rowand