From patchwork Tue Oct 27 13:50:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 289692 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 69E79C388F9 for ; Tue, 27 Oct 2020 15:34:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C78E22264 for ; Tue, 27 Oct 2020 15:34:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603812862; bh=bT4zdji2nWw1CSWlYhosL2pkLfy29MGk2M4rnXIvYOM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=APOp4XDhlnYr5oTHAH30yGvIcO/My9Zg30URTDO2w6RKBdjYpDAZgpmoAzFGTiM9m R06Ka2lH2Q7YanNefpkKmHyx1FGdsyjKvGyRMad9m8zEJs5LC/5ZftqUlsTkrJVghA NA+/1GsKLwPKdv7lANoclzkWJuZgqBRmfULMaCJc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1799951AbgJ0PeS (ORCPT ); Tue, 27 Oct 2020 11:34:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:52328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1799948AbgJ0PeS (ORCPT ); Tue, 27 Oct 2020 11:34:18 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 112FF2225E; Tue, 27 Oct 2020 15:34:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603812857; bh=bT4zdji2nWw1CSWlYhosL2pkLfy29MGk2M4rnXIvYOM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jTnARZ0NKZl/87aGZB2yf/cARYSe9AwDA/9dz7DngwEgRiVtB2z2qLNZnY0P5Az44 Q+UJezJot28Z9UYSxYdPaWtKsRkm7yad3q7jf81OhHntJv+NBy367R70TmlcUGymrS KbY8QnIQvAhC+noXEvlkLeCaIw+Cz/do49mU3aYc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Lee Jones , Sasha Levin Subject: [PATCH 5.9 355/757] mfd: syscon: Dont free allocated name for regmap_config Date: Tue, 27 Oct 2020 14:50:05 +0100 Message-Id: <20201027135507.222445643@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135450.497324313@linuxfoundation.org> References: <20201027135450.497324313@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier [ Upstream commit 529a1101212a785c5df92c314b0e718287150c3b ] The name allocated for the regmap_config structure is freed pretty early, right after the registration of the MMIO region. Unfortunately, that doesn't follow the life cycle that debugfs expects, as it can access the name field long after the free has occurred. Move the free on the error path, and keep it forever otherwise. Fixes: e15d7f2b81d2 ("mfd: syscon: Use a unique name with regmap_config") Signed-off-by: Marc Zyngier Signed-off-by: Lee Jones Signed-off-by: Sasha Levin --- drivers/mfd/syscon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c index df5cebb372a59..ca465794ea9c8 100644 --- a/drivers/mfd/syscon.c +++ b/drivers/mfd/syscon.c @@ -108,7 +108,6 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_clk) 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); @@ -145,6 +144,7 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_clk) regmap_exit(regmap); err_regmap: iounmap(base); + kfree(syscon_config.name); err_map: kfree(syscon); return ERR_PTR(ret);