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 B0989C4332F for ; Thu, 17 Nov 2022 08:48:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=2XzEh/tjcXYieJZgFLzZSDMLM+obcp3/CPx3Qj8MK2c=; b=lQH/rZQ1CRAzT8 +zPk8hMzqzFMe9MurOlNnBozLGSdr/vX8fCxpLGDWMVr1I2zn44fEp/uXlqFdLgPf27dzgRN+AfaQ jVhu5LwNSlm30YXxHblUYJTF1kBNhOFT8syPhLkosOngA8Je6Riq1NTxA9A8WtqTlmBut2h36sKow TSOOToMzf5Y6nM+tJwESrxdP+rSYu3dXrfjr9q8GLJv1eMQaLvhoI1wFZV3V/Rde2GHK4Jjiikp7b D18UweIDlKk3LL1hnt/SDGnvQClvDe+pmZfPjmDIzu1+Z8i8KF1K1gtD5TR+Plb7aGHayYW26Xtf8 fHl0cE/9u6EpK0punU5g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovaY1-00BnXR-0m; Thu, 17 Nov 2022 08:47:01 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovaXb-00BnC0-Pm for linux-arm-kernel@lists.infradead.org; Thu, 17 Nov 2022 08:46:37 +0000 Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NCYMP0M6TzqSW9; Thu, 17 Nov 2022 16:42:41 +0800 (CST) Received: from huawei.com (10.175.112.208) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 17 Nov 2022 16:45:58 +0800 From: Yuan Can To: , , CC: Subject: [PATCH] soc: realview: Fix memory leak in realview_soc_probe() Date: Thu, 17 Nov 2022 08:44:09 +0000 Message-ID: <20221117084409.58772-1-yuancan@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.175.112.208] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221117_004636_034324_C02504C2 X-CRM114-Status: GOOD ( 10.80 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If of_property_read_string() failed, soc_dev_attr should be freed before return, otherwise the soc_dev_attr leaked. Fixes: a2974c9c1f83 ("soc: add driver for the ARM RealView") Signed-off-by: Yuan Can --- drivers/soc/versatile/soc-realview.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/soc/versatile/soc-realview.c b/drivers/soc/versatile/soc-realview.c index c6876d232d8f..ac7e976b3e06 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"; -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel