From patchwork Wed Nov 23 13:58:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiu Jianfeng X-Patchwork-Id: 24995 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b599:b0:88:f841:fdc9 with SMTP id df25csp2152571dyb; Wed, 23 Nov 2022 06:06:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf42gwz6s9OlyEJI/uxZa+yi33u0JMxj8E4i40Nd2Xn9gRffJv2G78FjQETatgAVdkjjeiX5 X-Received: by 2002:a63:fa49:0:b0:476:f92f:885b with SMTP id g9-20020a63fa49000000b00476f92f885bmr14629008pgk.31.1669212406108; Wed, 23 Nov 2022 06:06:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669212406; cv=none; d=google.com; s=arc-20160816; b=XmCeghrmu6DaeYjwjeVf2G0tdN0HpcKQXHDMj/qbxbqiOTRm4hng3b7KbSRILGOzgm tppqZoF40HFcy0ReNvT8iMIxMgPtxLxzF1YrJyyENskzz4NzjX10h3JEOp7EkY/KHgAl DrYZrOE+IqlVpfVNtqb4jOTIORxSUynVKTuHpf2COaMiHm0cRxYeAXM1vB/vBv/BdRSI StJiXAjNsGCv/7OlQtfN41aBhxXP/qPJMo4u6uPNabgihX7ydcNNKr1Y4HMq5NC/cHm9 is/11tqW1TCIuY6dCMjjxPKuFrA6iWfsc6E1iREN0oILTStnWUBlRqhO9e3MKUFbcYkr DQBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=jipvfgi9p8gTDxl+dNT72Ms7PEce9swZvQZdemx8C6A=; b=BZufGLIXirLBf5mj7OxZ1LYszJyZGwYf2bK7Q9PsfRqsBvLRUjsRhnSQGAT3UTmB8d FxaEW7L++2CgFg2FONdOUMXKG8lM2eg0ZH7VZSnHXx2VBIEv25uTdFmjsbSclHMVY0p6 oYfXI4N8QLwmKondj7+0YByjVNVdFxlzV0lediHhbczr57KEJzFJ47pBcY7irQKRBla7 1feKnCwBwhhCx3y5CJJfsPkP8f80yZJgTyOgfXQLlGNQ6V6URmOUKcWxA0/6Q0Hon8t3 GbSheN0ads1f6SEvulCMLb3yWceythCT/3955GMuklI9hSvealJz0cRC9IeiaYS/CLPb jTfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x4-20020a63db44000000b00477b8c80220si2257970pgi.301.2022.11.23.06.06.25; Wed, 23 Nov 2022 06:06:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238530AbiKWOFg (ORCPT + 99 others); Wed, 23 Nov 2022 09:05:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238477AbiKWOFJ (ORCPT ); Wed, 23 Nov 2022 09:05:09 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3F3B5C745 for ; Wed, 23 Nov 2022 06:01:14 -0800 (PST) Received: from dggpeml500023.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NHN4M152WzJns8; Wed, 23 Nov 2022 21:57:55 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.58) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 23 Nov 2022 22:01:11 +0800 From: Xiu Jianfeng To: , CC: , , Subject: [PATCH] soc: aspeed: Fix memory leak issue in aspeed_socinfo_init() Date: Wed, 23 Nov 2022 21:58:08 +0800 Message-ID: <20221123135808.171048-1-xiujianfeng@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.174.58] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500023.china.huawei.com (7.185.36.114) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750296067613622739?= X-GMAIL-MSGID: =?utf-8?q?1750296067613622739?= If soc_device_register() fails, @attrs->machine may have allocated string, it should be freed before return error, otherwise will cause memory leak issue, fix it. Fixes: e0218dca5787 ("soc: aspeed: Add soc info driver") Signed-off-by: Xiu Jianfeng --- drivers/soc/aspeed/aspeed-socinfo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/soc/aspeed/aspeed-socinfo.c b/drivers/soc/aspeed/aspeed-socinfo.c index 1ca140356a08..3f759121dc00 100644 --- a/drivers/soc/aspeed/aspeed-socinfo.c +++ b/drivers/soc/aspeed/aspeed-socinfo.c @@ -137,6 +137,7 @@ static int __init aspeed_socinfo_init(void) soc_dev = soc_device_register(attrs); if (IS_ERR(soc_dev)) { + kfree(attrs->machine); kfree(attrs->soc_id); kfree(attrs->serial_number); kfree(attrs);