From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4540F3491D5; Fri, 21 Nov 2025 13:38:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763732310; cv=none; b=KcA7MauXxKt9hH4nCbqdNn16YLlZVatz9KDQsX8RmtUXMdzb3U4swrGn9yqIYRv/2HmDR34pK0D1r1YDPlZqbTVGDEtnMvfveFzKLC448vraPiVPHnEZYkR3OSCvf1qC8k5OoVs03mI2LMhF4sIyRvkHbrJlO1httVIyIeAODVM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763732310; c=relaxed/simple; bh=ZcFE7u72Lua0KIvuQLOuZmzNvpse4QnBSLEyG1Poh0g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UGAzjbCgL6y9bGwA59CzrDIf8Nx29njPGwAWiH0asIKIYWKVoVTq5M9wDQiHcFIv4OyAJrsSikTH8Moxe6Ydf46q2hQc8cFuqO2MWeRBJTdgHuSR2g8hMgm/+IPhqLUGM/AUcXYr2RaeH/iVh9G8JInrbr/XjBbph/RrBHa7qTM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hwTXuIZe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="hwTXuIZe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC764C4CEF1; Fri, 21 Nov 2025 13:38:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1763732310; bh=ZcFE7u72Lua0KIvuQLOuZmzNvpse4QnBSLEyG1Poh0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hwTXuIZeObp6u65DeH8jQ4HOibop/d5HCs1irwjXfvjGZJr6z3pkDSZ+wCQhBC31N EHNnYsh7ZqDJBMRov6jqwvbwsKH6vmPrwLFOCCpKmtVfAtv/13S7NMo67guxW8C94i uC56G7OVeshYZFe+luFLgIlB/8NS6gS1m8MwHToo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Neil Armstrong , Bartosz Golaszewski , Linus Walleij , Sasha Levin Subject: [PATCH 6.6 077/529] pinctrl: keembay: release allocated memory in detach path Date: Fri, 21 Nov 2025 14:06:16 +0100 Message-ID: <20251121130233.762500049@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251121130230.985163914@linuxfoundation.org> References: <20251121130230.985163914@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bartosz Golaszewski [ Upstream commit aae7a2876c3b39d07aa7655ea082af8e7862f3a5 ] Unlike all the other allocations in this driver, the memory for storing the pin function descriptions allocated with kcalloc() and later resized with krealloc() is never freed. Use devres like elsewhere to handle that. While at it - replace krealloc() with more suitable devm_krealloc_array(). Note: the logic in this module is pretty convoluted and could probably use some revisiting, we should probably be able to calculate the exact amount of memory needed in advance or even skip the allocation altogether and just add each function to the radix tree separately. Tested-by: Neil Armstrong Signed-off-by: Bartosz Golaszewski Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/pinctrl/pinctrl-keembay.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/pinctrl-keembay.c b/drivers/pinctrl/pinctrl-keembay.c index 152c35bce8ecc..94b11a23829f6 100644 --- a/drivers/pinctrl/pinctrl-keembay.c +++ b/drivers/pinctrl/pinctrl-keembay.c @@ -1606,7 +1606,8 @@ static int keembay_build_functions(struct keembay_pinctrl *kpc) * being part of 8 (hw maximum) globally unique muxes. */ kpc->nfuncs = 0; - keembay_funcs = kcalloc(kpc->npins * 8, sizeof(*keembay_funcs), GFP_KERNEL); + keembay_funcs = devm_kcalloc(kpc->dev, kpc->npins * 8, + sizeof(*keembay_funcs), GFP_KERNEL); if (!keembay_funcs) return -ENOMEM; @@ -1637,7 +1638,9 @@ static int keembay_build_functions(struct keembay_pinctrl *kpc) } /* Reallocate memory based on actual number of functions */ - new_funcs = krealloc(keembay_funcs, kpc->nfuncs * sizeof(*new_funcs), GFP_KERNEL); + new_funcs = devm_krealloc_array(kpc->dev, keembay_funcs, + kpc->nfuncs, sizeof(*new_funcs), + GFP_KERNEL); if (!new_funcs) { kfree(keembay_funcs); return -ENOMEM; -- 2.51.0