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 90792248883; Tue, 11 Nov 2025 01:00:55 +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=1762822855; cv=none; b=qGlCuA3XHgZUGSnQVQGrEz1tvJZI7ST7OMxqYmhD/pPQJIFGABrt3OrHy2TwKCQZqjOECrSt6yUz0w2N76BIX3b+2AJpOQvMtf7ayZVp9UmlOSt+1MJJcEMxX6xfAV88tqpblKEcK8dZgpmX+2rZA1rb/zcsVcNs1GSasvvl+7w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762822855; c=relaxed/simple; bh=AwozPR3pZh4eGZgKBgD+j4VjkIOrvmWvYT8Ii/3RRpc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XLIlrp2JbKwB3kiBEyF3679x30gaMndRiCMFAlR91LbLrJ4EfYnHepYVdexK6ppl7cMDdsP2MHi/ZSahWZNoDbG6RJDip5HoyEJ0/RCUVK7TWjbRFZjsyQgmbTCx6RAvd1Dziwj1CqNqQ5+zU1QW+9hB0a2kbOQQfCXto8OxvxQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bpJWQgZb; 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="bpJWQgZb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BEA7C4CEF5; Tue, 11 Nov 2025 01:00:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1762822855; bh=AwozPR3pZh4eGZgKBgD+j4VjkIOrvmWvYT8Ii/3RRpc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bpJWQgZbqZYYiGy11j+3niH8UW2Zo+Eh0cVvY1m4KHZuJGLncMZorTl1n98GONUZh JzM9P5aQN47zZNEsLRsTq6DDCkph92ZCx7nOhGA0j+7jLW4ueiMskzWxktqq9zsQlL Ri2WXI5d+Yp4P/vJvMP7jflOIyzktRqBRMU9riw0= 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.12 121/565] pinctrl: keembay: release allocated memory in detach path Date: Tue, 11 Nov 2025 09:39:37 +0900 Message-ID: <20251111004529.677178824@linuxfoundation.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251111004526.816196597@linuxfoundation.org> References: <20251111004526.816196597@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.12-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 b693f4787044c..b1124d3e50bff 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