Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp14591661rwb; Mon, 28 Nov 2022 02:58:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf6G9lMYear5gGc9dD8NkWkQPOr6Nif5051Qus70vM47I8gwGyl+7n4c+D1daBa2gj6PMVfh X-Received: by 2002:a17:907:874f:b0:7b5:e91:adf9 with SMTP id qo15-20020a170907874f00b007b50e91adf9mr16439884ejc.277.1669633133712; Mon, 28 Nov 2022 02:58:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669633133; cv=none; d=google.com; s=arc-20160816; b=sjhb3PT5dlqr6cjN04SAzT0cOSMHMgyGNtQ+rncr9loOE3lExw8olB/Uibtm/PiN8K SpOYSCaKB9gLIZAh/pagEVUMCjUZO2NDthvhMRjYBXn/rwDMFOvwDN61qLfuhdFS43z+ CGNIIc8aRTgq4+GF4vVHJSH7zdbmjSHAhyQ3eG6vS7ytlqeJaTIma6F4D2Dcphq+H9DC Jnv9Y8MR6bWbCvVznGtwcJZdjQAv6zLoIa9PhprBXVccZq9t4zTiiH0EdfHdQrlB2yZg 2lgWKUln7kft+aKJQKwH3yCf0UdafNzXeDysaQcikuAsd3nNTvL234MALjk9mZ15z86J KjEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=efk1h/h24mIiu3EK2a4IL03bgDH7nV3bBJXkYyz7Uv8=; b=XlIjOMy9RKdFNMpAFEDzKtbK/KGezraOFfQkeb0shTx1grgLz1ReL0ThrASn5dv8zB 92/2qmEzSTlLii54ZBN8ronca0Ge2szv/tKGhP3LUDN2qCgdQJi8l1FSb1761Tt4ZZMh PXuBtR2fzxPjN17YWNmavcHYkIO9j/9x/vDYzvPteNnnBkn/yxRqLvC25WvFBpFC6QP3 bMbQ98J4uM5vZzJCaGHViNSBMDoDbyf6OU2cNpzWwt0hLPSqljuJ4VBKiDHF9US6Pc03 xVkmmo7CWCbx35qRLLHDZZ08fg3+wn48tIHySA+3PFZpymtHW6xoQMSwDK8+njhmoJvX be0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=J1LdcDHI; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s7-20020a056402520700b00462847f2128si11350894edd.107.2022.11.28.02.58.30; Mon, 28 Nov 2022 02:58:53 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=J1LdcDHI; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230384AbiK1Kpq (ORCPT + 84 others); Mon, 28 Nov 2022 05:45:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229787AbiK1Kpn (ORCPT ); Mon, 28 Nov 2022 05:45:43 -0500 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16D3DDF1F for ; Mon, 28 Nov 2022 02:45:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669632343; x=1701168343; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=ot71st/2utMfdONzhlAwUYwqxVknRLimMxul6O7ei5U=; b=J1LdcDHIVpp7MPsAm9wlsRI3CN1jzXgoHDc7d9mcHc3URJY+Y14bwqM9 igpXQ6ay8vu+ubtN0yKR+QdVeFwmBbAO1zGaK7mSdid4FsaspaVrdt2qP 0+CJu7gmJrWyyyol6FNgVhhI3HuBKhJtxUV18N2mDB8070hrwjaZUgAyk hTsCmPHLbQsfiMZ/StGQ4ZtBasWb7W5w0eoVg+VaOOoTZEjbDmOccEWZQ 2FbR5dkhoDrYss5KG7zWpkYVCxKGpA0ozFirg+bLvQpwqG6iF32SEJNmm b13wHpVNYNZ/g4DNk3JfGPLoNIAT0Yrs4HGGOBPsfBv1S4WA9UYBJ0OE9 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10544"; a="379058285" X-IronPort-AV: E=Sophos;i="5.96,200,1665471600"; d="scan'208";a="379058285" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2022 02:45:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10544"; a="888372010" X-IronPort-AV: E=Sophos;i="5.96,200,1665471600"; d="scan'208";a="888372010" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga006.fm.intel.com with ESMTP; 28 Nov 2022 02:45:41 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1ozbdr-0015ES-1N; Mon, 28 Nov 2022 12:45:39 +0200 Date: Mon, 28 Nov 2022 12:45:39 +0200 From: Andy Shevchenko To: Jianglei Nie Cc: ojeda@kernel.org, geert+renesas@glider.be, linux-kernel@vger.kernel.org, kernel test robot Subject: Re: [PATCH v2] auxdisplay: hd44780: Fix potential memory leak in hd44780_remove() Message-ID: References: <20221128084421.8626-1-niejianglei2021@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221128084421.8626-1-niejianglei2021@163.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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 On Mon, Nov 28, 2022 at 04:44:21PM +0800, Jianglei Nie wrote: > hd44780_probe() allocates a memory chunk for hd with kzalloc() and > makes "lcd->drvdata->hd44780" point to it. When we call hd44780_remove(), > we should release all relevant memory and resource. But "lcd->drvdata > ->hd44780" is not released, which will lead to a memory leak. > > We should release the "lcd->drvdata->hd44780" in hd44780_remove() to fix > the memory leak bug. Better now! See my comments below. After addressing them, Reviewed-by: Andy Shevchenko > Fixes: 41c8d0adf3c4 ("auxdisplay: hd44780: Fix memory leak on ->remove()") Fixes: 718e05ed92ec ("auxdisplay: Introduce hd44780_common.[ch]") What you found has nothing to do with the issue. Issue has been introduced later on. > Reported-by: kernel test robot > Signed-off-by: Jianglei Nie > --- > drivers/auxdisplay/hd44780.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/auxdisplay/hd44780.c b/drivers/auxdisplay/hd44780.c > index 8b2a0eb3f32a..f4800a946bd8 100644 > --- a/drivers/auxdisplay/hd44780.c > +++ b/drivers/auxdisplay/hd44780.c > @@ -322,8 +322,10 @@ static int hd44780_probe(struct platform_device *pdev) > static int hd44780_remove(struct platform_device *pdev) > { > struct charlcd *lcd = platform_get_drvdata(pdev); > + struct hd44780_common *hdc = (struct hd44780_common *)lcd->drvdata; drvdata member is type of void *, no need to do an explicit casting as per C standard. > charlcd_unregister(lcd); > + kfree(hdc->hd44780); > kfree(lcd->drvdata); > > kfree(lcd); > -- > 2.25.1 > -- With Best Regards, Andy Shevchenko