From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D136FC2D0A3 for ; Thu, 12 Nov 2020 11:22:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FE4E22228 for ; Thu, 12 Nov 2020 11:22:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="fLq5eB6x" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727789AbgKLLW1 (ORCPT ); Thu, 12 Nov 2020 06:22:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727035AbgKLLWZ (ORCPT ); Thu, 12 Nov 2020 06:22:25 -0500 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A67CFC0613D1 for ; Thu, 12 Nov 2020 03:22:25 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id p22so4934222wmg.3 for ; Thu, 12 Nov 2020 03:22:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=TBhNsZQdgwb8L9O2fB8roWDMxhxwp24jJn01jx9v16I=; b=fLq5eB6xzW9c5XCZ9Dg4JnnRSMdtdI+CZBnL2CzEAEuKEuS39D6ZFcEek4RjXyOFit FDsjiHViAwjEIIO8c+1TwFxg0hlixayoQxpJbx43404PHsw+cZhwl2+JrkuDpeyZ/q6L RuVwDShqzMYZh7BcQFtFj4U/kcqZQPp1ICr/OYZ08q8eF5JJeMecAn72mD6sPifocbmH 12yTSJQ22RPaY6ToOa4u+rIMJHLU8q/+wl0DVsc8wVpZO9YOviis1H9apNn8c5nV1WqM DiRwbxDT39NY06+BSaKjC+L5g56SmFVxOKJKH/yAs43bDCztvdoEdJjUdR2PCQeJWwoS 1S9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=TBhNsZQdgwb8L9O2fB8roWDMxhxwp24jJn01jx9v16I=; b=MmVe/MMITwKdYcg7ltwuhZYXlUCzsLrfJcobOVeVQOGubhw1DXMm1GrRCQcsIkaDKQ IvwJzYGs8LrePhEws7Ye0TL593PqGg++Ut/PXIGEOGChPEWapwlV7UzRr0iM5GVYO4Rl KB+7XLNR9O5ThVmesTLpMaMy493ucREh2vF25DbLB5CuAUEJxmNT6f7ks79f+0w9JAn/ sWvdfGGYE7fwz95foMHFIW1oVnpxvTHXtA1sq9ops9yFlgJ3cHjb55+lTUeUcRXYl6aj VU8LLwWgtTJfKXxICK+K0QJ0lKsDJGBClOaHuWpNWGKg7ujSZqho3GVHHIE/TGorzKI+ Eg/g== X-Gm-Message-State: AOAM533/BS9DI7PZwDG04KeDcN6WekpL7slSz/hv+kthGliW6CvMQaOO V+V6IgaFzymBgUe/Eq3HoG9VMw== X-Google-Smtp-Source: ABdhPJwTMc42ZSo5QtIlCWsJfNkBbfVitTMYGPJhgclF1n2ZOjp9XjJdfrQd7R638dyC6QUROHA+pA== X-Received: by 2002:a1c:b70b:: with SMTP id h11mr9650589wmf.185.1605180144219; Thu, 12 Nov 2020 03:22:24 -0800 (PST) Received: from ?IPv6:2a01:e34:ed2f:f020:6971:b700:3764:fa96? ([2a01:e34:ed2f:f020:6971:b700:3764:fa96]) by smtp.googlemail.com with ESMTPSA id m22sm6500180wrb.97.2020.11.12.03.22.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Nov 2020 03:22:23 -0800 (PST) Subject: Re: [Resend][PATCH] drivers/thermal: fix potential memleak in error branch To: Bernard , Zhang Rui , Amit Kucheria , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com References: From: Daniel Lezcano Message-ID: Date: Thu, 12 Nov 2020 12:22:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On 10/11/2020 09:10, Bernard wrote: > 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); > } Please fix the function with the proper error path and the labels. Thanks -- Daniel -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog