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 0845F3232; Wed, 2 Oct 2024 14:48:29 +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=1727880510; cv=none; b=FNzxLJ5+ycQCUkGvh2pNOrXpeQtDp0OK3EcKj1Pmu1uKjs+XMOBrRe4oq/RpOBbDoXA6sEBb6Z8vxVRwYBmVobCavyH7yYTIlzDdDWnEBGiV935ZYf/Rp61yJQQMDzIIzuuT5DjuhWB0wb/4maURrcIfp/PPj8lou9t0P89iiV4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727880510; c=relaxed/simple; bh=H096K4bzy041asc60t+KUn88Jfh9QGmdjCNPp1YWQHo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kqRGMVWk7RuoQg8kfKtGFStbO+0BGqilrupQvc1Zke3vjM3ulZ+jDViXWnTbCbgEhDLfc6uyMLL4aG0e6E/Ir/ZDd2u4Del/o3gf0AK5mcvauLf1Ca98700+PZIaK4iVeAsxXhLPSYWKLi2cIya+F0QhvHo9Pt2PjbrNBNxHtkg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=sqcVLm1k; 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="sqcVLm1k" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4ACA8C4CEC2; Wed, 2 Oct 2024 14:48:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1727880509; bh=H096K4bzy041asc60t+KUn88Jfh9QGmdjCNPp1YWQHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sqcVLm1k076a10P4h1K+U8WiUdBGSJZ1rA6wUOHdKNLj7SZe4bsrlTAJg0lLkH4Eq 5o4RKmQQh9CrN8Vx8+9uoR1DLNmNyjbhI3LTXN/Cd20wGoRfPXe1PS7WJ3yjNAdr2W zANjeKs+lf7YfhRibRGXKraNu3Gvg/SikvahwVXQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Krzysztof Kozlowski , Linus Walleij , Sasha Levin Subject: [PATCH 6.6 484/538] soc: versatile: realview: fix soc_dev leak during device remove Date: Wed, 2 Oct 2024 15:02:03 +0200 Message-ID: <20241002125811.546797751@linuxfoundation.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241002125751.964700919@linuxfoundation.org> References: <20241002125751.964700919@linuxfoundation.org> User-Agent: quilt/0.67 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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Krzysztof Kozlowski [ Upstream commit c774f2564c0086c23f5269fd4691f233756bf075 ] If device is unbound, the soc_dev should be unregistered to prevent memory leak. Fixes: a2974c9c1f83 ("soc: add driver for the ARM RealView") Cc: stable@vger.kernel.org Signed-off-by: Krzysztof Kozlowski Link: https://lore.kernel.org/20240825-soc-dev-fixes-v1-3-ff4b35abed83@linaro.org Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/soc/versatile/soc-realview.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/soc/versatile/soc-realview.c b/drivers/soc/versatile/soc-realview.c index d304ee69287af..cf91abe07d38d 100644 --- a/drivers/soc/versatile/soc-realview.c +++ b/drivers/soc/versatile/soc-realview.c @@ -4,6 +4,7 @@ * * Author: Linus Walleij */ +#include #include #include #include @@ -81,6 +82,13 @@ static struct attribute *realview_attrs[] = { ATTRIBUTE_GROUPS(realview); +static void realview_soc_socdev_release(void *data) +{ + struct soc_device *soc_dev = data; + + soc_device_unregister(soc_dev); +} + static int realview_soc_probe(struct platform_device *pdev) { struct regmap *syscon_regmap; @@ -109,6 +117,11 @@ static int realview_soc_probe(struct platform_device *pdev) if (IS_ERR(soc_dev)) return -ENODEV; + ret = devm_add_action_or_reset(&pdev->dev, realview_soc_socdev_release, + soc_dev); + if (ret) + return ret; + ret = regmap_read(syscon_regmap, REALVIEW_SYS_ID_OFFSET, &realview_coreid); if (ret) -- 2.43.0