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=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 361F2C432C0 for ; Tue, 19 Nov 2019 01:27:45 +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 D805E20692 for ; Tue, 19 Nov 2019 01:27:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ellerman.id.au header.i=@ellerman.id.au header.b="KzKyJmP3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D805E20692 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au 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 47H7VQ3WSJzDqRn for ; Tue, 19 Nov 2019 12:27:42 +1100 (AEDT) Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 47H7SK5SbfzDqBg for ; Tue, 19 Nov 2019 12:25:53 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ellerman.id.au header.i=@ellerman.id.au header.b="KzKyJmP3"; dkim-atps=neutral Received: by ozlabs.org (Postfix) id 47H7SK4ftXz9sPV; Tue, 19 Nov 2019 12:25:53 +1100 (AEDT) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 47H7SK3KqXz9sPL; Tue, 19 Nov 2019 12:25:52 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ellerman.id.au; s=201909; t=1574126753; bh=NZ8qGC6/6aodqG+MaWv/C0hTYe0EAx7mOuwW7JFMbe0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=KzKyJmP37ZtmSeTWOr14jDsCEgrpyPyxPKqlc1ZcDBgmyWxqMRq/6hbrYSu6JiKga 2IP9j0JrO0J8EqBqoESLpMI2Bgpzks1BHZVZStXDbxEPjiMUSxJb9TBi9ok7dl+nMr 2llUd6r0C5uazwae8j9AO+5Z7AO4kq4J+2wltM9l3MVSS7EPGAMWY4D3adOEmEBgrH nsHerFwVQKC+zCDrVZKHcfiCjXLVZ1FfjaOOagd6a4X7w7/w2eHQcnFH6lPpYnSh9Z e7inC6FRAhYrRU/KMvRVBGiJu4iE02OXrodYvhBQzaGzsFjx7+snwzN8mNwGBcdUcf 9DjM5aMMlwbqg== From: Michael Ellerman To: Erhard Furtner , linuxppc-dev@ozlabs.org Subject: Re: [PATCH] of: unittest: fix memory leak in attach_node_and_children In-Reply-To: <20191114184334.2866770-1-erhard_f@mailbox.org> References: <20191114184334.2866770-1-erhard_f@mailbox.org> Date: Tue, 19 Nov 2019 12:25:52 +1100 Message-ID: <87eey4d5cv.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain 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: Erhard Furtner Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Erhard Furtner writes: > In attach_node_and_children memory is allocated for full_name via > kasprintf. If the condition of the 1st if is not met the function > returns early without freeing the memory. Add a kfree() to fix that. It would be good to mention that this was detected with kmemleak. It looks like the leak was introduced by this commit: Fixes: 5babefb7f7ab ("of: unittest: allow base devicetree to have symbol metadata") > Signed-off-by: Erhard Furtner > --- > drivers/of/unittest.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) Reviewed-by: Michael Ellerman Because this patch is to drivers/of, you need to send it to the right folks. You can work out who with: $ ./scripts/get_maintainer.pl -f drivers/of/unittest.c robh+dt@kernel.org frowand.list@gmail.com devicetree@vger.kernel.org linux-kernel@vger.kernel.org So to get it merged you should send a v2 (ie. with "PATCH v2" in the subject), and Cc those people above as well as linuxppc-dev. You should include the Fixes and Reviewed-by tags I've posted above in your v2. cheers > diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c > index 92e895d86458..ca7823eef2b4 100644 > --- a/drivers/of/unittest.c > +++ b/drivers/of/unittest.c > @@ -1146,8 +1146,10 @@ static void attach_node_and_children(struct device_node *np) > full_name = kasprintf(GFP_KERNEL, "%pOF", np); > > if (!strcmp(full_name, "/__local_fixups__") || > - !strcmp(full_name, "/__fixups__")) > + !strcmp(full_name, "/__fixups__")) { > + kfree(full_name); > return; > + } > > dup = of_find_node_by_path(full_name); > kfree(full_name); > -- > 2.23.0