Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8619870ybl; Thu, 16 Jan 2020 21:05:50 -0800 (PST) X-Google-Smtp-Source: APXvYqwFmF0TdUtSS0/R1R4Cm2ubQZ+S2JOFtz8tzjabB7kLLlCdu9iZ0VkCgDXHOe/6kWP0ACn9 X-Received: by 2002:a05:6808:4c7:: with SMTP id a7mr2104283oie.83.1579237550085; Thu, 16 Jan 2020 21:05:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579237550; cv=none; d=google.com; s=arc-20160816; b=sTRw3FYJhfqVChiM02rO/XrBNC51btcKCYrxFTKcGPDmIxoiSOPm6uS7PVLuQWQrYW nEpZk+a71A+MuWC9Xf2dWoJsapT1CB9VV4nDcaSmgQeila5uoe86Sl5DFXHXaUpM01dd Ca0MWSxrcI4U2q1S3NDCfYvyKS6MiVmOL1NduBtqZZxfQ+0AMTgBgL3NSNds4rprrydP S7EAxt6FGRezT0JcI2CVn8CAvO16V53Vd4TWlBayT0y18WeEDj/PKigXjY1TaXNssnZU VU2dLUKptZs/OupfCHzVYR0dryYPbHuSQb1dbuk+an4Oefx9DMC/O6wwM/GhyCG2lkgL 0KVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=w3vXZ283SlQ2gDt2w9v//GnlUxlvkTcHlFT+fggopxA=; b=UO+HOBPXT3acuiDaMGLQPRmZbSI6aeSuAINvUG7lgK6grk2DaE7YqlT4AZOPynX58o xhT14p6C4QAK2ZdP1mdOU1TIsSZmMIQVqwiUZBqKHNDibLfq65S8041STMR+6SucVnVr 2ReGSaxaqZHcYAo7dXK+UvgK7Cf/6PY94tqr9CxJANH1gTdRD75to7y9seRA3NznS7bj OMkMhGOjtOMQhU/0l2UwCEjxrJoBbwsXdH1s6TyHw1fxnZlI7PxDBjHLHim6QT4l2Sw0 wG/z13CM6/V8Lh7CgVKc7vThyLnr9s3uJVvA9xkjFHlg4s9oDvGlURZkiobnMEGQ2PB/ R2oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="X/7YMH2Q"; 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 38si15315490otj.136.2020.01.16.21.05.35; Thu, 16 Jan 2020 21:05:50 -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; dkim=pass header.i=@kernel.org header.s=default header.b="X/7YMH2Q"; 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 S2403977AbgAPXo5 (ORCPT + 99 others); Thu, 16 Jan 2020 18:44:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:52128 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731489AbgAPXXi (ORCPT ); Thu, 16 Jan 2020 18:23:38 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C795B2176D; Thu, 16 Jan 2020 23:23:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579217018; bh=7XkkFiByh7e8tI6otoiNQUWOwsrLM1DR+5pw5Gn0nEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X/7YMH2Q/Rs7ffqgRLLCtttka3hxiopVxmKSqpH4cJOY76ggEPtVDn3LxkjuMqI4+ PuLWF3rXH/pE7AYkdyxQvKPuwurIRHGE8EzXajmbr9nCFlM+zOzWWF0Xy+FIXEmAuN OeRZsDr6gQ33jGPMm4he+euu3j4wIr8L2HQvyVOM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tomi Valkeinen , Tero Kristo , Kishon Vijay Abraham I , Stephen Boyd Subject: [PATCH 5.4 114/203] clk: Fix memory leak in clk_unregister() Date: Fri, 17 Jan 2020 00:17:11 +0100 Message-Id: <20200116231755.394698166@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200116231745.218684830@linuxfoundation.org> References: <20200116231745.218684830@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kishon Vijay Abraham I commit 8247470772beb38822f226c99a2ed8c195f6b438 upstream. Memory allocated in alloc_clk() for 'struct clk' and 'const char *con_id' while invoking clk_register() is never freed in clk_unregister(), resulting in kmemleak showing the following backtrace. backtrace: [<00000000546f5dd0>] kmem_cache_alloc+0x18c/0x270 [<0000000073a32862>] alloc_clk+0x30/0x70 [<0000000082942480>] __clk_register+0xc8/0x760 [<000000005c859fca>] devm_clk_register+0x54/0xb0 [<00000000868834a8>] 0xffff800008c60950 [<00000000d5a80534>] platform_drv_probe+0x50/0xa0 [<000000001b3889fc>] really_probe+0x108/0x348 [<00000000953fa60a>] driver_probe_device+0x58/0x100 [<0000000008acc17c>] device_driver_attach+0x6c/0x90 [<0000000022813df3>] __driver_attach+0x84/0xc8 [<00000000448d5443>] bus_for_each_dev+0x74/0xc8 [<00000000294aa93f>] driver_attach+0x20/0x28 [<00000000e5e52626>] bus_add_driver+0x148/0x1f0 [<000000001de21efc>] driver_register+0x60/0x110 [<00000000af07c068>] __platform_driver_register+0x40/0x48 [<0000000060fa80ee>] 0xffff800008c66020 Fix it here. Cc: Tomi Valkeinen Cc: Tero Kristo Signed-off-by: Kishon Vijay Abraham I Link: https://lkml.kernel.org/r/20191022071153.21118-1-kishon@ti.com Fixes: 1df4046a93e0 ("clk: Combine __clk_get() and __clk_create_clk()") Signed-off-by: Stephen Boyd Signed-off-by: Greg Kroah-Hartman --- drivers/clk/clk.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3886,6 +3886,7 @@ void clk_unregister(struct clk *clk) __func__, clk->core->name); kref_put(&clk->core->ref, __clk_release); + free_clk(clk); unlock: clk_prepare_unlock(); }