Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp2988328pxx; Sun, 1 Nov 2020 18:13:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJyS3smsPspSMfdsCcsYSUY8Kd6qDxMmduQXcfO1Gb4IKACN43SrGm4hc1hO3gf6e0kpx0tY X-Received: by 2002:a17:906:6686:: with SMTP id z6mr4740190ejo.554.1604283222434; Sun, 01 Nov 2020 18:13:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604283222; cv=none; d=google.com; s=arc-20160816; b=dwl7qiamJpJh6VshiGSgWhG8eTfS1lvnKhJcKnQS6MUVUXCztcZBZczFgwRqDwT65A W1GbJFVzOzp/kTpMoyPc5B9WfIZVI83HzWDYQw5mvTEz/4/qYuzI6BoRYvJ7iZ1rOvUM rKgNEt5kur9aj881Rqxhp84ykui636i/r+IPseN81NOtIDxO2s1bbMueQWaJCfWkvXN6 2NasDjNyxVeVE17to/l3dQtIlWimM8ZeU1Oclb6sB3Ewgmq3PzbwGxhm+0APzNHCWvCd XwkPP5KtrzcFDmQfKZu54I77XzHqF1tgMTVUfLuZDSdA6nhVx7yubnDt4rJC0clM9Jrs SzFQ== 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=vK22iuMRFDBGyheIOEUrOJpibbbgUbyOq1BSELhKBjE=; b=U/m8aZRfa8pkjBaDAyw/oEDl7ppVUQHcl3hyi3QLQAzFCwqVz+kZ0NFbgIR1mcYjbA 9UhYsfMFIWqPfePsZ+DXvbw1PPWjlWUsKYhkaRNOsoVbR4Vborfh7m1kQ5Q6Z4iDqmRh vIXe8/yYBndF/k2zD71aasYVC78MgPsPgJZ9Ah6sskUrcYN+MxUJro0X6+0YkonuSA0v SDyHPYvV4lLqB9v3yh6zdKAIV6OqgLAjhDaiAl82LXrVKyvak8gs8eVi3+hFDI6EHVui xSkKU7OxdF+koEIZrCTr4WoYNO2P3NqBMWpS3PLFepQgyG1CiLR7W+/NMPt7NzLnGvm9 fwcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t13si9759333edv.198.2020.11.01.18.13.19; Sun, 01 Nov 2020 18:13:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727517AbgKBCMA (ORCPT + 99 others); Sun, 1 Nov 2020 21:12:00 -0500 Received: from mail-m17613.qiye.163.com ([59.111.176.13]:7019 "EHLO mail-m17613.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727409AbgKBCMA (ORCPT ); Sun, 1 Nov 2020 21:12:00 -0500 Received: from ubuntu.localdomain (unknown [58.213.83.157]) by mail-m17613.qiye.163.com (Hmail) with ESMTPA id CE486482B20; Mon, 2 Nov 2020 10:11:57 +0800 (CST) From: Bernard Zhao To: Zhang Rui , Daniel Lezcano , Amit Kucheria , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, Bernard Zhao Subject: [PATCH] drivers/thermal: fix potential memleak in error branch Date: Sun, 1 Nov 2020 18:11:48 -0800 Message-Id: <20201102021149.3047-1-bernard@vivo.com> X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZSBoYSU8YTR9LGUwYVkpNS09JQ0hKSkNLSEpVEwETFhoSFyQUDg9ZV1kWGg8SFR0UWU FZT0tIVUpKS0hKQ1VLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Ky46Kww*Cz8pHSEPLR0UAjID LywwCUlVSlVKTUtPSUNISkpDT0xCVTMWGhIXVRkeCRUaCR87DRINFFUYFBZFWVdZEgtZQVlOQ1VJ SkhVQ0hVSk5MWVdZCAFZQUpNQ0g3Bg++ X-HM-Tid: 0a7586b9b19593bakuwsce486482b20 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Function __thermal_cooling_device_register, when device_register failed, cdev is not free after error value return, this may bring in potential memleak. Signed-off-by: Bernard Zhao --- drivers/thermal/thermal_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 3d1e0033bf3e..e4bee15dfa1f 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1125,6 +1125,7 @@ __thermal_cooling_device_register(struct device_node *np, if (result) { ida_simple_remove(&thermal_cdev_ida, cdev->id); put_device(&cdev->device); + kfree(cdev); return ERR_PTR(result); } -- 2.29.0