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 892B44C97; Tue, 11 Nov 2025 00:59:03 +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=1762822743; cv=none; b=XF6ZlyYHoajXgdpcEePZLEaIj2zhDGI/j1Q9k3Q0nh3bNjUS8R6LrtXRm9x3n6WpwnpO4CaWOKG77drJnXg/ylvQImAb0XhHpExYK0kgVkR7kdp5QOah6ucfcYb7cGS2dFf+vKhe04FgThAKe5qArNF9DXPc19zJ332RgdlE+9Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762822743; c=relaxed/simple; bh=Kt1Eb5n1QxzfFJejMe2JD2lPqMEfNrssV1Y45f3flVc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fy+q/8FGuki47ZkU5keUID+OPXOixcRDvqq0/QP4HAzGlJhm0SnFM9SclpAv1zKodAVnVD0kPSGG2N2g4M8nKT/ft5MHq45FGjuPhwlKbam3zF55rO/64JKb6E+Dvz0A3n9eCX1/zYr5prm/72oNWUhVDaVWRggI/Lio4I8V6dM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=R/NTvUK4; 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="R/NTvUK4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F883C4CEFB; Tue, 11 Nov 2025 00:59:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1762822743; bh=Kt1Eb5n1QxzfFJejMe2JD2lPqMEfNrssV1Y45f3flVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R/NTvUK4y1kqmsdO/QpR1KnOKQkFCXhjInXSVchkvzHR7XSmbW/S5A98Xbtr2TpVa C9MH/9WKLDh74rlGjtjiTX1DPhP2xHyCYW/ho8DdK5QKwmkQv0WUVQ+EQ4+1ASZ7ip U7+m6A5ycTfGLj09EE8cqY9xDhPzQgoVGtIeJCdA= 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.17 159/849] pinctrl: keembay: release allocated memory in detach path Date: Tue, 11 Nov 2025 09:35:29 +0900 Message-ID: <20251111004540.277454791@linuxfoundation.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251111004536.460310036@linuxfoundation.org> References: <20251111004536.460310036@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.17-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 60cf017498b32..6aefcbc313099 100644 --- a/drivers/pinctrl/pinctrl-keembay.c +++ b/drivers/pinctrl/pinctrl-keembay.c @@ -1603,7 +1603,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; @@ -1634,7 +1635,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