Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp711823pxv; Thu, 15 Jul 2021 14:09:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvcBCP9dy+zYloErzSfXs5+nk32RBWPTWLw30PFvWrSwZpxoAsrDRmVTLp5/3tpLvwrdTq X-Received: by 2002:a17:906:4b46:: with SMTP id j6mr7649640ejv.247.1626383392374; Thu, 15 Jul 2021 14:09:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626383392; cv=none; d=google.com; s=arc-20160816; b=s7L/9ZWITGMJFsMC/1jWp0Y2O0Z75/SDnB0+YoEkOl8PbTGCq+LTyGuO0aTVHaOL5I CDDcYAM/hq3dEV5cj4n9C33XXqEeZtcPkQIT8eBjgEm80QDD/6l7xT+h3PsOeK32Sqq2 bFTWIkzyCkcOJ+30x91nthb5YaH5Y0EUmAOrQ2UQwMw/4g8xeas6PG4C54XJgVReZ914 6utDrEZ4ZgNDOyLIfTx9D+CUgZp9gV/me3FVzTMUQHSOI3YWOFTPz/aP8sa9LVo23TMI /RTtbHeasHCB5C6tzBQOMEW0+e+UQ/gPzfDuKUG6h4QItQrsTXAAseYwV+13NShA5U3R pDaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3TEyPq90Qgso1lXZYl538rfIOPXCe8ZkGI81bZLtTTI=; b=gYcc+sjMsiJ7pIKvzaGwe0woDjICtgfl0Q50Mv0334Gr6Q4O7k1egSdXHq3z4zoGTK BtTWY8SSJQUtpJ1q01R70hSezsYkSjGshsFI/UEFQN1mnzPMum8sLZNi8wbK7QAaUpfd p35WieOHHYRjMYSxwMeIZYVhXXL3UFr2FP17RnxoEZMIbFOypJ2n1BLipU22f39VJGxo ZdzH/FssicCX6h6zpznp1txmtoa+IQveDsIdfWPqu+IbbvqctjBJGRTZP9qKMSnbOgJf ZTB+OB85U1Ixh6ddtVaPtIn2AOPGby1y7AUocQHq3TS4wtkyEXQiYa/NmECXr6oN6Gkv /RuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="zR3t3sG/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o23si8693254ejn.329.2021.07.15.14.09.29; Thu, 15 Jul 2021 14:09:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="zR3t3sG/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243373AbhGOTVe (ORCPT + 99 others); Thu, 15 Jul 2021 15:21:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:38158 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242725AbhGOTFd (ORCPT ); Thu, 15 Jul 2021 15:05:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6FF7661158; Thu, 15 Jul 2021 19:01:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375712; bh=oeHtHu3SOTnq8xDXXFlMf7eT9quDwllg4ho5H1FEKSM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zR3t3sG/sW88w/M9AkMy1GRUU6+41R5M3ZZnNh2wxjKiZDA3SCGYNCP0hwdUOue+Z 77H7+xJikWV09tVkKexRLIj7YIfGi8WjPj9v/XrcErSGyMF7vga2lPiA5EMugelSYl mtgk2UK+Owyk5TLMVMgnaVLKIXRxXwoWKIjgurDE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Meng Li , Lee Jones Subject: [PATCH 5.12 202/242] mfd: syscon: Free the allocated name field of struct regmap_config Date: Thu, 15 Jul 2021 20:39:24 +0200 Message-Id: <20210715182628.839008673@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Limeng commit 56a1188159cb2b87fbcb5a7a7afb38a4dd9db0c1 upstream. The commit 529a1101212a("mfd: syscon: Don't free allocated name for regmap_config") doesn't free the allocated name field of struct regmap_config, but introduce a memory leak. There is another commit 94cc89eb8fa5("regmap: debugfs: Fix handling of name string for debugfs init delays") fixing this debugfs init issue from root cause. With this fixing, the name field in struct regmap_debugfs_node is removed. When initialize debugfs for syscon driver, the name field of struct regmap_config is not used anymore. So, the allocated name field of struct regmap_config is need to be freed directly after regmap initialization to avoid memory leak. Cc: stable@vger.kernel.org Fixes: 529a1101212a("mfd: syscon: Don't free allocated name for regmap_config") Signed-off-by: Meng Li Signed-off-by: Lee Jones Signed-off-by: Greg Kroah-Hartman --- drivers/mfd/syscon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/mfd/syscon.c +++ b/drivers/mfd/syscon.c @@ -108,6 +108,7 @@ static struct syscon *of_syscon_register syscon_config.max_register = resource_size(&res) - reg_io_width; regmap = regmap_init_mmio(NULL, base, &syscon_config); + kfree(syscon_config.name); if (IS_ERR(regmap)) { pr_err("regmap init failed\n"); ret = PTR_ERR(regmap); @@ -144,7 +145,6 @@ err_clk: regmap_exit(regmap); err_regmap: iounmap(base); - kfree(syscon_config.name); err_map: kfree(syscon); return ERR_PTR(ret);