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 1B10F1BDC3; Mon, 14 Oct 2024 15:08:15 +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=1728918495; cv=none; b=pSHg5Jdyop7Ra+ADQHBxKCQ2Cr6OQtosJFkde/xuHNdaQHqaJjM/uBIZU4G/9psPtgH26TmgdL6g2JKMxQ9Ea2H9Tc8SWGqEYvgaR+16+wIuMKdqqIsEBJXgB/SL3N+cgcGlGbIxgB1jTNrgNp75J/fOx4v6/+dFv+p68f2+MhY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918495; c=relaxed/simple; bh=eoB/xJJ3OXDv7nDPGMS3bvBLDoEnVWrrkd820VyGvts=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MSJ6XcIKSJy6KHsZuZlR9BKD3AF3g7khFqyPM1356gruGj3jhsKxtTbuZSZsLogTSOGeztMexgXMddS08J6OxKWY1ETBr4lfv+JRPXh9k46I08DZ/IzH1VVijcOsmne70pJAdvPtg0GVqC0mjcLHmriyOInFMCnNDhfWpy9qMGM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=I4p8iplB; 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="I4p8iplB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8174AC4CEC3; Mon, 14 Oct 2024 15:08:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728918495; bh=eoB/xJJ3OXDv7nDPGMS3bvBLDoEnVWrrkd820VyGvts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I4p8iplBB6dPtw1rbYkNGJTLBo8LheBod6uMaXkzCTH/LzYckVqLqMWZqH+D7Sq1i uylT2n43aiEHiAhF4IjJRDuq91XXnqwhygmQOrJffRCxRCgKYVEZmyKz5hEKKMjVGS EkIOyAuvh7QcMCcU4/1FbdTMu2eg3mlAc9NQak3c= 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.1 341/798] soc: versatile: realview: fix memory leak during device remove Date: Mon, 14 Oct 2024 16:14:55 +0200 Message-ID: <20241014141231.344225248@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241014141217.941104064@linuxfoundation.org> References: <20241014141217.941104064@linuxfoundation.org> User-Agent: quilt/0.67 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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Krzysztof Kozlowski [ Upstream commit 1c4f26a41f9d052f334f6ae629e01f598ed93508 ] If device is unbound, the memory allocated for soc_dev_attr should be freed to prevent leaks. Signed-off-by: Krzysztof Kozlowski Link: https://lore.kernel.org/20240825-soc-dev-fixes-v1-2-ff4b35abed83@linaro.org Signed-off-by: Linus Walleij Stable-dep-of: c774f2564c00 ("soc: versatile: realview: fix soc_dev leak during device remove") Signed-off-by: Sasha Levin --- drivers/soc/versatile/soc-realview.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/soc/versatile/soc-realview.c b/drivers/soc/versatile/soc-realview.c index c6876d232d8fd..d304ee69287af 100644 --- a/drivers/soc/versatile/soc-realview.c +++ b/drivers/soc/versatile/soc-realview.c @@ -93,7 +93,7 @@ static int realview_soc_probe(struct platform_device *pdev) if (IS_ERR(syscon_regmap)) return PTR_ERR(syscon_regmap); - soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + soc_dev_attr = devm_kzalloc(&pdev->dev, sizeof(*soc_dev_attr), GFP_KERNEL); if (!soc_dev_attr) return -ENOMEM; @@ -106,10 +106,9 @@ static int realview_soc_probe(struct platform_device *pdev) soc_dev_attr->family = "Versatile"; soc_dev_attr->custom_attr_group = realview_groups[0]; soc_dev = soc_device_register(soc_dev_attr); - if (IS_ERR(soc_dev)) { - kfree(soc_dev_attr); + if (IS_ERR(soc_dev)) return -ENODEV; - } + ret = regmap_read(syscon_regmap, REALVIEW_SYS_ID_OFFSET, &realview_coreid); if (ret) -- 2.43.0