From patchwork Sun Aug 25 18:05:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13776864 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9B906C5320E for ; Sun, 25 Aug 2024 18:08:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Px08219UxWUPNfHVakRaFgAR3n14DqjgVtECE2v++7A=; b=cnoNJ9R9wTqNtCBnVcxke5xps+ 2qC9dTDS8+pQ6YUxzKaSUO4zu+/iti0Vttpr27b/5GS9sjo8aMWBIKJyFGrAdNoV6eqxx+MtdwFyU MHiW1O02MV6JwPJCDvA5MrvQ2T3xU/nMyOd6zbXIuv/nJ/cJEYwfmePVlmqCDr/ZNs5j0VVShW9O+ F/wE7pTounR2RiS4Lb3GFIKWwClkHDK3TIa+uMMQd4PC96TXeDsjtWtZCjQHhk/GpnBTEBS8HHYoy AXX9/F43Pyvd19gOxDJaJ0NogSCaooeeSfVY85XU6Ou27FCw0BDde9/GlglmdncYA7cfZPIr2wEzX 7bv98sOQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siHet-00000004mED-3NMd; Sun, 25 Aug 2024 18:08:12 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siHch-00000004ljd-06CT for linux-arm-kernel@lists.infradead.org; Sun, 25 Aug 2024 18:05:56 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-42808a69a93so5553905e9.3 for ; Sun, 25 Aug 2024 11:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724609153; x=1725213953; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Px08219UxWUPNfHVakRaFgAR3n14DqjgVtECE2v++7A=; b=NKYV/Ix0ypqXXY9rasmj73kl4JkACdUxe+s2tZEN/QLR6sOn0jtujAVYqE9I0nZQ37 3/OLjFOX8d6ZTAKOq2ire5j6S2Hctey8drHp2YWBjnjlr57Off9i3ezwbIazTXy+V9Ml 0I7k/XaGrxBolQ0dejuBUdxzW4KKzHc++oCWToZU0GkrufpA9GYAMmcFbpJesR/IUPHH 6GORt5eI2+zjNXn7EX9cIwU/Hua8JuJipLLJkcWgDwBIGGkSzHquCxmqUrvvyHNZU3L3 Vmo7IiXzFnw/jiBJm7sY0RqsTvSffcYwxkjRuuDO4LpRvtBRIaA8Z8J/ta6CkcXN/SKr Ktlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724609153; x=1725213953; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Px08219UxWUPNfHVakRaFgAR3n14DqjgVtECE2v++7A=; b=ezQhOFtXOrinULg1psktYFyciLi38VggqrII6Yr9JkMuh1Fr9u4GxsjidRo3HaTc+D 8Qvp2mLUyaLmZIblTfpfSFPHIUqn1I1slSYJNM7no2t02eaRyK93Vgyq3sb8Py0lGIn2 YsE9S27lZ5ZWrTeCpo513mCFpVmIhSUFNutdJ2mo1EcSGvA/ND0a47TKV8NByjfpcifD iwgA7yU4bSYi2qvhcQ4/kfXEhnoGX+wSvVXjhG8hrjifl28jUwRMVa5OkC2sJKr5GWMz k952TCOX52E0SrHXi7Mf4JCLYq72WT3iAkrDM1UEUkBu2eUn0J6RiybnRLAF5dDEFRY2 iOtw== X-Gm-Message-State: AOJu0YylrKoFfWmN5sVW/O+BnjJsLsB36ydrSIYZ1itmxoUSSOfx/Q1+ aQ7vyEsRJdOtUiwYjJYVzHUpIR/lYrGXqjk93uO21qSiylxixpLzPhKqYuuBuDc= X-Google-Smtp-Source: AGHT+IEOT5xXGWdNvfDQNreEbDE2fIXiA0ElOhNl5gFlct2Dn9/6HfSzNT2X0our2pg7Lo1zqVH7UQ== X-Received: by 2002:a05:600c:1c0a:b0:427:9f6c:e4bc with SMTP id 5b1f17b1804b1-42acca11e53mr35783945e9.5.1724609153076; Sun, 25 Aug 2024 11:05:53 -0700 (PDT) Received: from [127.0.1.1] ([178.197.222.82]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37311dca113sm6438736f8f.16.2024.08.25.11.05.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Aug 2024 11:05:52 -0700 (PDT) From: Krzysztof Kozlowski Date: Sun, 25 Aug 2024 20:05:23 +0200 Subject: [PATCH 2/4] soc: versatile: realview: fix memory leak during device remove MIME-Version: 1.0 Message-Id: <20240825-soc-dev-fixes-v1-2-ff4b35abed83@linaro.org> References: <20240825-soc-dev-fixes-v1-0-ff4b35abed83@linaro.org> In-Reply-To: <20240825-soc-dev-fixes-v1-0-ff4b35abed83@linaro.org> To: Linus Walleij , Arnd Bergmann Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1269; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=gLo2MRTXsFeq02SUdCwpMzugi/rrrP2OWGn4eDr68Nw=; b=kA0DAAoBwTdm5oaLg9cByyZiAGbLcnij66rKNDQtIYEA/f6SQA3a3xsRiZyOLMcWfi9UNQw/9 IkCMwQAAQoAHRYhBN3SYig9ERsjO264qME3ZuaGi4PXBQJmy3J4AAoJEME3ZuaGi4PXiaQP/36v XoZ+079iF8+XR3eHzzetL+GsXUMs7VVe8Z7VjIbpeWaqoiaCGLFlFjDWVQjJu9/wxPW5Fpi5qZb 93SXGFvnX4nL8n3TyKzCWnLRN0zV0LUQmo87Wf27T/JpSD9FJ37vChPQKdxPrXL7ZlgwVgyKHNM i2CG6bt17mvx8xux1a+QBTmlHFzpYVBkRwHtwQLyp3S88q/QPseosKB841/9b0bSrO6gRwVp0j6 gDd4xYZyEY2yCKRvJ/9ROQhXsrwMTcYPRC6VhLh1UwG5Uyk35e4+KE0dzO72fL7/F4vfN6m/Z7L VtenMv7B6zRR5beMseJKW/GlWMQiNfj+oSASbrZCd0qGOng0uPPnf1wiUXFrU/QuN68Bab4N5uM PLNkSTRj+E+C431Ol6ymM0NyZ9DdrctHOeWzSn6F0PVj5uAeBycy2wHLC1e8pquVOkui/mD7xc5 vgu3dTsKu0OmPjuwmwM7kGph8hUO8UwDd/DvkQbcg8WOvloa0j7vBdlipbvf2WAliJKDb8vFTq6 +9fwT554fce37h+MT0+6JtNUIY6u8pOU1kQ7nDfmPrSsW2zVOTO2aznPzkpOnXjnHR4LqqiJuWZ qM/caLV1KxpuT5QT9Nmff3YG8NAwvcoGjsWgkV4IwoJd4TCEOyDJ+PlEn5iGemw1xx0WMCwf4LC 4sdAw X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240825_110555_102503_9E831D1B X-CRM114-Status: GOOD ( 12.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If device is unbound, the memory allocated for soc_dev_attr should be freed to prevent leaks. Signed-off-by: Krzysztof Kozlowski --- 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 c6876d232d8f..d304ee69287a 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)