Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7421673rwb; Wed, 23 Nov 2022 06:23:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf5g7h/PRg80zPX0F7VaIy6Ons6mVxgnLKZ4QfFahuaawrgPD3UQkR5L4M23/cUADzL3U2OM X-Received: by 2002:a17:902:d191:b0:189:1d93:1435 with SMTP id m17-20020a170902d19100b001891d931435mr9608836plb.105.1669213413106; Wed, 23 Nov 2022 06:23:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669213413; cv=none; d=google.com; s=arc-20160816; b=y+gQFpl1ifYIkWgcab6/h5S8xM1vfOFafQ3bpppHrRr8rpZINzhAEZoBZiSLhC7AC8 DgUsRrBihKBHZVTRSMMcuzn6KalSr3Xcc/1589WgpjT1z3s9dJQiGqTQuerYCw/ViN3N gsi1Aw9dLcesUq5vmDsEX3VckbF+XMzBHLaMV7AMyLq8Bc6LLb+GY3LY0hm5UoFkE9xI 59MuXAGjbwyteRtyCmHDqmIsy4hcx/XpaTz1envowY/zXcBzG35P3YM2PSL7sKlDkZYF 9CUiKMAIzxqjhjSXG/PXGvSg4adNU0BPg8SkP5DK27ITwqw6qwUqL52GBRxSSI/NCVSF +Ojg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020a6566d1000000b00476e63cf8a4si17799883pgw.129.2022.11.23.06.23.18; Wed, 23 Nov 2022 06:23:33 -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 + 89 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 Content-Type: text/plain 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 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); -- 2.17.1