Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp659760pxv; Thu, 15 Jul 2021 12:44:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEvv+3zWIRCNllACN93+6TqdxSoxg+B2NWzU1WzECc+/udqV4TJUGSi+UxGLDAf2lwuiBS X-Received: by 2002:aa7:c808:: with SMTP id a8mr9394616edt.245.1626378295302; Thu, 15 Jul 2021 12:44:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626378295; cv=none; d=google.com; s=arc-20160816; b=csQIvjTB2mGPIC6bDso00h7/qAoo5KvLzRyKOuu+DpsuKN/cmW8VlC2Az11Fb5GaNe FN7aj1TPuCBK1yTjfyMgMaRGbOk/mA7vqNWxgIn/DHCTv8wVEFYUKc4S/auykObpHq50 Btx5V/fGKiSwBOGy+gwtmJVaulGru0jM22nRubNbBG5beKnGJC7VT5Iyrm7+uv7/1crl PxeXcGeXGjYFxfZVxBxowDGkUxl+N1D8yT7zAHPACS/P29JL4ANoBmxcFewu3VqNc5Dc T4RsHfMq7tO8boqNEFcorxpihjc9hpaj778PdRazSIqlSmcvlHTDAzJYKJxlMN3ItOMn HqJA== 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=wcGkHltjLChzwObH/DDVAX2xCzDY7NoxAiQfS7a7KMtQGEKMMfiQSiyXJ6TQRir7rW h2eJf0yY15PEdsWd1vW1hrjhotrg9/0uC7Hh9cr+2oIDPe6CySkDdjIWrwoXNwQXkZI/ YWkk3lffg6JqtghM5/mn08cNyxROHQyvmNmvFBIZdVhnvaR7vuZAedlgqt8f9Xx7cPxf z/NUDFZOOoOkT3U66u9Yt8kJDsbGrJvQZVPHJhZ2TpjjDjxowY0JrTZ8umRg6g14UWvI 8RFIStLQC4502LYFe0fkWRla69C++a0woq1TfSB8B1VN2T0qsYejli7e1BHFsb0UdV9w Emkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=olqwvRar; 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 bh4si9789731ejb.680.2021.07.15.12.44.32; Thu, 15 Jul 2021 12:44:55 -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=olqwvRar; 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 S245644AbhGOTqE (ORCPT + 99 others); Thu, 15 Jul 2021 15:46:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:50894 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243838AbhGOTP6 (ORCPT ); Thu, 15 Jul 2021 15:15:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 16DE061370; Thu, 15 Jul 2021 19:12:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376332; bh=oeHtHu3SOTnq8xDXXFlMf7eT9quDwllg4ho5H1FEKSM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=olqwvRaregawMTHlxlcWVNpwm7n+mFE4P4caGJG8V2p6usMEJOWag79+SVkECh+00 wO2UwYQIjkHg7oDLPn1r24Izf6SSY2Po2cGfsDvuMC+alzinRZHXURtF37LUkM4kSH ASV6qxw1kD0YzF9GsxCiCLPrSmwWTcIsYZMBGql4= 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.13 226/266] mfd: syscon: Free the allocated name field of struct regmap_config Date: Thu, 15 Jul 2021 20:39:41 +0200 Message-Id: <20210715182648.972371678@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@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);