Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1611389rdb; Thu, 7 Dec 2023 04:21:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+eUeT7oPL/Ca7p8nhUehcan27mUk4RZsJbkFm1W9rW9eP+sRqe6KtWudIyZvOPWtSbK8h X-Received: by 2002:a17:90a:660a:b0:286:6cc1:781b with SMTP id l10-20020a17090a660a00b002866cc1781bmr2554651pjj.94.1701951681723; Thu, 07 Dec 2023 04:21:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701951681; cv=none; d=google.com; s=arc-20160816; b=a4S1DSxYcSauTdACwTf2lAu6hcq9s+rqAD4+amrDWkMui4r6VqrGJVXR39hrj8NZeG GujtDTE+UfncZTw+Oi46lA8TX469MRZYlwixoJxo0g6jlcLfG3J63sgq8zDfjsrVBQ5a LNaXlX10UXdzQQbXcmKkznVFTu5XvTkG7vR/xpcR61YMC4y3P+b+yxRLqm9/NXypbj4M 6ZJ9YauGdpbNc5juwxQ0gm9+BNKVN5KbTv5kGun9waNK+UlKT5d0exXCGHSIZ64mYlJL e5snUZeEBtkSgrdQas1a0Mka42SJsLpnlGxck2e9CUHDNnQZZXu2xjan3jmY1L0pbmvd Lymg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=5yUjfvMs5ec8uElYnt9+DP2ABF4NZ2euk8ILZN8aPyU=; fh=i2SP9ES9D6ZY1zRZihM830lZOwomfyT4bWLua97oyII=; b=BnvJzJS0MoHRZFlqZvn8N6Z1Ky55n1xqEpfg57vyma/UHrJec2Hz6NSV1B3vV5+/Ji r69DpCeKbSN7tYVgayuAAezsHJIP/D7RCtRUfE0paCF6Hd4Iv1FalhpTZjFjVDRB6lbh w5gWzZ6PFSgqrbZdX1mBXbuWyU92wmtCfsWGz4z2h06gkzHfrrMRPGnnZeMvPqFwmYPw R3fMISvr9yINOfLBevRqtQtSArkoWBJfSi/9GcVot80vyKURFMG9/Nk8MIiLzi96av7J FjcFQ3XSo6bAEZGiy9QC0ZlxwxXaImRIJELIvxlDv0/8wN2UZz+1AAe00g/d+lzM/Ykw 0mzA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id lw11-20020a17090b180b00b0028651c89270si1067679pjb.98.2023.12.07.04.21.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 04:21:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 821EA80ABFE5; Thu, 7 Dec 2023 04:21:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379279AbjLGMVC (ORCPT + 99 others); Thu, 7 Dec 2023 07:21:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379418AbjLGMUr (ORCPT ); Thu, 7 Dec 2023 07:20:47 -0500 Received: from zg8tndyumtaxlji0oc4xnzya.icoremail.net (zg8tndyumtaxlji0oc4xnzya.icoremail.net [46.101.248.176]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EE4C81708 for ; Thu, 7 Dec 2023 04:20:34 -0800 (PST) Received: from luzhipeng.223.5.5.5 (unknown [125.120.145.92]) by mail-app2 (Coremail) with SMTP id by_KCgCnrEyJuHFlGHdYAA--.47665S2; Thu, 07 Dec 2023 20:20:26 +0800 (CST) From: Zhipeng Lu To: alexious@zju.edu.cn Cc: Linus Walleij , Arnd Bergmann , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] soc: realview: fix two memleaks in realview_soc_probe Date: Thu, 7 Dec 2023 20:19:31 +0800 Message-Id: <20231207121932.3353687-1-alexious@zju.edu.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: by_KCgCnrEyJuHFlGHdYAA--.47665S2 X-Coremail-Antispam: 1UD129KBjvJXoW7ArWDWF4UWFWUZFyftr4kCrg_yoW8GFyDpr WkGFyrAryUKFn5Z345Ca1DGFy5ta4Iya4j9r18Kanru3W5XryaqFyxXFyjyFyDJFZ5Cr45 Jw4DA3y8JFW3XFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkq14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc2xSY4AK67AK6ryU MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr 0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0E wIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJV W8JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAI cVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUb8sqJUUUUU== X-CM-SenderInfo: qrsrjiarszq6lmxovvfxof0/ X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 07 Dec 2023 04:21:19 -0800 (PST) When of_property_read_string fails, it should free soc_dev_attr allocated by kzalloc before. So as the failure of regmap_read, the soc_dev needs to be unregistered and soc_dev_attr needs to be freed. Fixes: a2974c9c1f83 ("soc: add driver for the ARM RealView") Signed-off-by: Zhipeng Lu --- drivers/soc/versatile/soc-realview.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/soc/versatile/soc-realview.c b/drivers/soc/versatile/soc-realview.c index c6876d232d8f..19c4a9599c9f 100644 --- a/drivers/soc/versatile/soc-realview.c +++ b/drivers/soc/versatile/soc-realview.c @@ -99,8 +99,10 @@ static int realview_soc_probe(struct platform_device *pdev) ret = of_property_read_string(np, "compatible", &soc_dev_attr->soc_id); - if (ret) + if (ret) { + kfree(soc_dev_attr); return -EINVAL; + } soc_dev_attr->machine = "RealView"; soc_dev_attr->family = "Versatile"; @@ -112,9 +114,11 @@ static int realview_soc_probe(struct platform_device *pdev) } ret = regmap_read(syscon_regmap, REALVIEW_SYS_ID_OFFSET, &realview_coreid); - if (ret) + if (ret) { + soc_device_unregister(soc_dev); + kfree(soc_dev_attr); return -ENODEV; - + } dev_info(&pdev->dev, "RealView Syscon Core ID: 0x%08x, HBI-%03x\n", realview_coreid, ((realview_coreid >> 16) & 0xfff)); -- 2.34.1