From patchwork Thu Apr 16 21:42:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 201916 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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 D95EBC352BE for ; Thu, 16 Apr 2020 21:44:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B7998221F9 for ; Thu, 16 Apr 2020 21:44:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EN9E/AtM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728157AbgDPVos (ORCPT ); Thu, 16 Apr 2020 17:44:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727972AbgDPVop (ORCPT ); Thu, 16 Apr 2020 17:44:45 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71246C061A0C; Thu, 16 Apr 2020 14:44:45 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id l25so326730qkk.3; Thu, 16 Apr 2020 14:44:45 -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=KlgFG+M3n9abjMqYN2fUYHQh7LbcgicpBKBoW2XqS7k=; b=EN9E/AtMGYsycKXsHLAOvljbsIVPHZurm3pkOxLWDdUHsZxrHYWnTa9C7V/HlsLSib p9wwP0zCWVMQtmh5RmzRyo9HsMLiglCvBqJNOzQjWWqSOFvyH7o4KH/5tXnvDwPaXFaL 4PwIvE2BCCICQtLnNTg1QiwZvbW8cA7iZ6sUoIMiRcowUGygnHyOy90tmhTtc/zSLBIX xVz2874iIt9kK+oRP2M6yIe76OpekpGt6wUgx8V+QBX3mvRUJRZ+MrSZ5MGhdvVYUJ7a +3YUriVDzCh97Y9qf/3rPqvEl+f3QFgki3FfveFOnWZwut2pNHlligttE6+SbfFKS78u FQUQ== 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=KlgFG+M3n9abjMqYN2fUYHQh7LbcgicpBKBoW2XqS7k=; b=ggfojVL7fZujvd2XDKnL2WfRG6ki+/gu9h1r/oACDlohJEVLCQQcInk0uajniiDhrA DrKeirIy3CT2sBzLcWbgOAd3jrUF2sMlCipDPRDPOCmGPYboNT4DQ7dJ4sM/fVdBiTs7 0U8XQ1er+NTAFfYabU/cmETeTsScCdfBXZLotwgYKwbh6uucN71IiEKA5jwUHKjK/wRr dBIgWS7B/BaL/XzUHqcMN2GQG+E9OJZNfB0HOVxAGcVSdGr3t+o5xVxppZhhCVaHUKIa 5Hdgj2svdT/N8ghUqfli2B+YY6/2kZXJOWGoOibBDrCrQ2cKcAS5mxxOrWxOSrlpIWsv V80A== X-Gm-Message-State: AGi0PuZzisnEqrOGDA3oUOuimXzhl1VTmayl4nb5/IWMoxanBA5/yM7M eBxVgXxyF1sCrTqJo3tl72E= X-Google-Smtp-Source: APiQypJno+bvZVNrX7XSnObtFbZHzCOvk4SdtwSQ/XavQBrMX063GCXwhjOx7xBEshZhItF3qpFF2w== X-Received: by 2002:ae9:ddc6:: with SMTP id r189mr162068qkf.14.1587073484738; Thu, 16 Apr 2020 14:44:44 -0700 (PDT) Received: from localhost.localdomain (c-73-88-245-53.hsd1.tn.comcast.net. [73.88.245.53]) by smtp.gmail.com with ESMTPSA id z34sm3164141qth.43.2020.04.16.14.44.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Apr 2020 14:44:44 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , pantelis.antoniou@konsulko.com Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Ellerman , "Erhard F." , Geert Uytterhoeven , Alan Tull Subject: [PATCH 1/5] of: unittest: kmemleak on changeset destroy Date: Thu, 16 Apr 2020 16:42:46 -0500 Message-Id: <1587073370-25963-2-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1587073370-25963-1-git-send-email-frowand.list@gmail.com> References: <1587073370-25963-1-git-send-email-frowand.list@gmail.com> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Frank Rowand kmemleak reports several memory leaks from devicetree unittest. This is the fix for problem 1 of 5. of_unittest_changeset() reaches deeply into the dynamic devicetree functions. Several nodes were left with an elevated reference count and thus were not properly cleaned up. Fix the reference counts so that the memory will be freed. Fixes: 201c910bd689 ("of: Transactional DT support.") Reported-by: Erhard F. Signed-off-by: Frank Rowand --- drivers/of/unittest.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 7e27670c3616..20ff2dfc3143 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -861,6 +861,10 @@ static void __init of_unittest_changeset(void) unittest(!of_changeset_revert(&chgset), "revert failed\n"); of_changeset_destroy(&chgset); + + of_node_put(n1); + of_node_put(n2); + of_node_put(n21); #endif } From patchwork Thu Apr 16 21:42:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 201914 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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, 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 74E52C2BA2B for ; Thu, 16 Apr 2020 21:45:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 520F7221F4 for ; Thu, 16 Apr 2020 21:45:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dLhuENUj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728331AbgDPVpB (ORCPT ); Thu, 16 Apr 2020 17:45:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728112AbgDPVor (ORCPT ); Thu, 16 Apr 2020 17:44:47 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BC3DC061A0C; Thu, 16 Apr 2020 14:44:47 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id y3so288501qky.8; Thu, 16 Apr 2020 14:44:47 -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=ri3GcCgI+is7U0tNUGQj9JVdWWpKjcSdhc08l7uOYfg=; b=dLhuENUjstK3nPmJgrivkwfLR0PIutDeYo8GfNiU5JR3nmw8Xy6nrbxF/3Jm/wSv2f iiA1VghcxRFdeoVnYlecj9fvz3BnCqIrS/E/DuoelUMOgW8HimzavT7PknL7X5Ntd+VS ifN07keBZCpcG6kxft91OyZ7CrZMlPv9IUJEhkJiXOjTQHBfgcMpxO1eOXy8sfx1uBnI 28OU1UenxghWZDXclfLTI023PWghnNjT7Af9eYhRTWBghIo5aQzEvnkU29LR6wiDDOqr aJhEjlBBZO7pZg9E+kiTpQv0Bp2p7nUmvV79n5ZGtvzkt/nzhoE/og9xm3Eli1ohtwG6 QgbA== 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=ri3GcCgI+is7U0tNUGQj9JVdWWpKjcSdhc08l7uOYfg=; b=nP17DMZj264vKlbps66A/cKqOeXRTDfze1fVJOEX2sbX3byUybm2LJyFttBQrg6/m0 E3FFrZb/tKQLBvR/RfKUDF6t0/3TMeT4nkYrakLgX43svPmoLM5I09+qpzQauvoUxQY/ 9g36tq/a3F5tgVUVAD+XAoO/Wx+cSIKBqvV6Akm9+ROy+8tHKH+6XezKsmvL114x4J9U 6Y7vOt0kHlXIcMqqFX2Iai1w+4xYg25DoQfjwXZYrKLIdxUVPzjYyhBjPfXkLdcSg3Uu U55ZulAuCB00ewKEh+tyDBXpxPYdJjxEo/sPrLVndrkWD0CnPmpDqq9113ddL2dzNcvo sOwA== X-Gm-Message-State: AGi0PuasZ7+jC91oZKaf1ftkbdfRBQ5Da1ObH7HEyrehH7RtcyJFJ4bL rNKYYPXk8vSSeeql/O3xwEs= X-Google-Smtp-Source: APiQypK5YPrgNfGWutFT5M7T6XGbyiU8Hyu8YP+4Buk3DQ0g671iwEqfk80lrw427qlDYbCtvIiSdA== X-Received: by 2002:a37:7302:: with SMTP id o2mr119945qkc.466.1587073486852; Thu, 16 Apr 2020 14:44:46 -0700 (PDT) Received: from localhost.localdomain (c-73-88-245-53.hsd1.tn.comcast.net. [73.88.245.53]) by smtp.gmail.com with ESMTPSA id z34sm3164141qth.43.2020.04.16.14.44.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Apr 2020 14:44:46 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , pantelis.antoniou@konsulko.com Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Ellerman , "Erhard F." , Geert Uytterhoeven , Alan Tull Subject: [PATCH 3/5] of: unittest: kmemleak in of_unittest_overlay_high_level() Date: Thu, 16 Apr 2020 16:42:48 -0500 Message-Id: <1587073370-25963-4-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1587073370-25963-1-git-send-email-frowand.list@gmail.com> References: <1587073370-25963-1-git-send-email-frowand.list@gmail.com> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Frank Rowand kmemleak reports several memory leaks from devicetree unittest. This is the fix for problem 3 of 5. of_unittest_overlay_high_level() failed to kfree the newly created property when the property named 'name' is skipped. Fixes: 39a751a4cb7e ("of: change overlay apply input data from unflattened to FDT") Reported-by: Erhard F. Signed-off-by: Frank Rowand --- drivers/of/unittest.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 4c7818276857..f238b7a3865d 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -3094,8 +3094,11 @@ static __init void of_unittest_overlay_high_level(void) goto err_unlock; } if (__of_add_property(of_symbols, new_prop)) { + kfree(new_prop->name); + kfree(new_prop->value); + kfree(new_prop); /* "name" auto-generated by unflatten */ - if (!strcmp(new_prop->name, "name")) + if (!strcmp(prop->name, "name")) continue; unittest(0, "duplicate property '%s' in overlay_base node __symbols__", prop->name); From patchwork Thu Apr 16 21:42:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 201915 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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, 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 5C57DC352BE for ; Thu, 16 Apr 2020 21:45:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 369FB221F4 for ; Thu, 16 Apr 2020 21:45:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U/wZmwFF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728277AbgDPVow (ORCPT ); Thu, 16 Apr 2020 17:44:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725843AbgDPVos (ORCPT ); Thu, 16 Apr 2020 17:44:48 -0400 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE45AC061A0C; Thu, 16 Apr 2020 14:44:48 -0700 (PDT) Received: by mail-qt1-x844.google.com with SMTP id b10so250842qtt.9; Thu, 16 Apr 2020 14:44:48 -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=sthAapj68aXnXI+RTvpMX6Wnzn0JdQZcGOOuG2S5PBw=; b=U/wZmwFFE2+EDMGQltvGpyA0vQDc9HEPWleqF6o//HJIleVvCBxrzqyG8LoupuNO6X aK/0TxVGE8qCSwwlHYSXVUe03ikiIy/WYtYMuRQN0SNUHHXj242GqrATPys++GD7vV4Y 3TOeUeyKOBBP8lrwyQ+bq2nglijA6+nm37+HefH/rH19DlNoAq78X/x7reN0X7MCfH0W qoD88FNNzlr/PM5xwW6EFMOZHjxOEkpgmDxIgYvORkRbzFGhXSENirIg9F4DBskJuopx rvza9knEBZd0+ThVTdcpykEXSu2Dmwtx/XZhgFAsBRwRWhZSUMWX4y5DILLEeZRMP/m7 5mBg== 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=sthAapj68aXnXI+RTvpMX6Wnzn0JdQZcGOOuG2S5PBw=; b=mv6P2aO3IzAQOt453cHtAfu8x2R0aRTbLdY7QcQwcq7omhvsb+Um9gyBOgqVfpvSVB G3JXx0EJUqW1Kk9BglKhDPrjLIvnV9T19lN1lNmBqgvnFejxGpkyCU9x1Qm6eYvVTFnK 78W88oJGc/1Ani3Rj7mTlwN/7Ccwhdrcw+2TFTxrVxYq5jxUS93vn4qKsu0WV8Lo5Q9L ThTMoKj16+9OXE/0GpdxKnPob9Cvd4jaduCqWyOInewgWodIVZCLluCcr7fKkfWRoXr/ lwkA1iamQhu9dUvkmjL1YdA5tCTFXQBEOMmHswve82bOgIpMz4h8ZECv5z7tG3kTrzEi /5ew== X-Gm-Message-State: AGi0PuZ6e9DE1JbsSOQGmuGvO276EB1A/ajtVICWtYxe9rAv9wHvFmbn qZN6u/ukz2FXZbtkAFCMTO0= X-Google-Smtp-Source: APiQypL6FrzR3vybWwRzyKZ+ZYw6voEB2hXvgpwAE4GXnyw43EMvCotfFZFjd2NKKnKJOQcqrGakHQ== X-Received: by 2002:ac8:71c1:: with SMTP id i1mr26103907qtp.280.1587073487971; Thu, 16 Apr 2020 14:44:47 -0700 (PDT) Received: from localhost.localdomain (c-73-88-245-53.hsd1.tn.comcast.net. [73.88.245.53]) by smtp.gmail.com with ESMTPSA id z34sm3164141qth.43.2020.04.16.14.44.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Apr 2020 14:44:47 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , pantelis.antoniou@konsulko.com Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Ellerman , "Erhard F." , Geert Uytterhoeven , Alan Tull Subject: [PATCH 4/5] of: overlay: kmemleak in dup_and_fixup_symbol_prop() Date: Thu, 16 Apr 2020 16:42:49 -0500 Message-Id: <1587073370-25963-5-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1587073370-25963-1-git-send-email-frowand.list@gmail.com> References: <1587073370-25963-1-git-send-email-frowand.list@gmail.com> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Frank Rowand kmemleak reports several memory leaks from devicetree unittest. This is the fix for problem 4 of 5. target_path was not freed in the non-error path. Fixes: e0a58f3e08d4 ("of: overlay: remove a dependency on device node full_name") Reported-by: Erhard F. Signed-off-by: Frank Rowand --- drivers/of/overlay.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index c9219fddf44b..50bbe0edf538 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -261,6 +261,8 @@ static struct property *dup_and_fixup_symbol_prop( of_property_set_flag(new_prop, OF_DYNAMIC); + kfree(target_path); + return new_prop; err_free_new_prop: