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 C6E742773F7; Fri, 21 Nov 2025 13:25:57 +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=1763731557; cv=none; b=ZrINc3ym5G6U7c1hT+de0yAEpi5R89jNZjXPmBMobBdirEcSxKl8xZ5KmtpNuAYXYFx8fQJcNU5hlsjQRHQoQFE+I/LC/30NPVeHSJ34OqthVg8yGtXy12Vh8hom45IRD9cP1pr6zK/0vVPEQhzUGFtlK87Ip1PjCvIdMdOVVT4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763731557; c=relaxed/simple; bh=drLnahT/i4d6C81bOIwv90iTw4egWBVCMmXgq2Vu2ak=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ugRt2KFrgIK6yQVhqlfxHkzERJqODHEPhE3H35D9Fe4KCMmqptPfQFEHVc6+1GW/fFpO5aBsTWWhD0d3ElCV9uhgqaITBYsfzTZN8ufb4MGf7GfZguua3YHG3y01dZHuWVMn+NMrfUq57PGO3741F0cNyL+LBeSKYzxyn9Ewa7I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0w+DvOTU; 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="0w+DvOTU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53963C4CEF1; Fri, 21 Nov 2025 13:25:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1763731557; bh=drLnahT/i4d6C81bOIwv90iTw4egWBVCMmXgq2Vu2ak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0w+DvOTUatU82rfgL+oBl0J5N2QQS6++B71GZHx5dV+qAbjPVS5mRskAnxPZkkw6Y XEiRAfwb8dwSEIPB39C4HI9X3g8O6s8iydD7SoQtY9ttm6TYOShtU4Wf6xVWlV4l7G 2H2axnz74Ovsq2RE9y9k126rchz2EZ6M6+oxRomE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Peter Griffin , Krzysztof Kozlowski , =?UTF-8?q?Andr=C3=A9=20Draszik?= , Marek Szyprowski , Ulf Hansson Subject: [PATCH 6.17 228/247] pmdomain: samsung: plug potential memleak during probe Date: Fri, 21 Nov 2025 14:12:55 +0100 Message-ID: <20251121130202.918558928@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251121130154.587656062@linuxfoundation.org> References: <20251121130154.587656062@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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: André Draszik commit 90c82941adf1986364e0f82c35cf59f2bf5f6a1d upstream. of_genpd_add_provider_simple() could fail, in which case this code leaks the domain name, pd->pd.name. Use devm_kstrdup_const() to plug this leak. As a side-effect, we can simplify existing error handling. Fixes: c09a3e6c97f0 ("soc: samsung: pm_domains: Convert to regular platform driver") Cc: stable@vger.kernel.org Reviewed-by: Peter Griffin Reviewed-by: Krzysztof Kozlowski Signed-off-by: André Draszik Tested-by: Marek Szyprowski Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/pmdomain/samsung/exynos-pm-domains.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) --- a/drivers/pmdomain/samsung/exynos-pm-domains.c +++ b/drivers/pmdomain/samsung/exynos-pm-domains.c @@ -92,13 +92,14 @@ static const struct of_device_id exynos_ { }, }; -static const char *exynos_get_domain_name(struct device_node *node) +static const char *exynos_get_domain_name(struct device *dev, + struct device_node *node) { const char *name; if (of_property_read_string(node, "label", &name) < 0) name = kbasename(node->full_name); - return kstrdup_const(name, GFP_KERNEL); + return devm_kstrdup_const(dev, name, GFP_KERNEL); } static int exynos_pd_probe(struct platform_device *pdev) @@ -115,15 +116,13 @@ static int exynos_pd_probe(struct platfo if (!pd) return -ENOMEM; - pd->pd.name = exynos_get_domain_name(np); + pd->pd.name = exynos_get_domain_name(dev, np); if (!pd->pd.name) return -ENOMEM; pd->base = of_iomap(np, 0); - if (!pd->base) { - kfree_const(pd->pd.name); + if (!pd->base) return -ENODEV; - } pd->pd.power_off = exynos_pd_power_off; pd->pd.power_on = exynos_pd_power_on;