Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp517060rwb; Tue, 29 Nov 2022 01:36:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf7k2gzd8MtYQSCJAQ/yhiKw2+x/Hbh64605CFntQE/Eexnr1acNafCF8z20D3ozVN5/j0Mk X-Received: by 2002:a62:1c95:0:b0:571:baf8:8945 with SMTP id c143-20020a621c95000000b00571baf88945mr36332361pfc.83.1669714591106; Tue, 29 Nov 2022 01:36:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669714591; cv=none; d=google.com; s=arc-20160816; b=oJdafD1XJ128RWvbnOwISvTB7aUrhdgxaOGk7QMksMDBzXAPB6adlmeUvBgfk1mDwN ZdNNYi2J+454F+ChoZlmDILwIYYzTNRen+NwkjmtzUeAPAkoF8R5AQY6gogU4Id3eXni DzE44lmzJ8BCL4zFfGTh2bbbvbQOUOh8u0oVrlczyODUoFjrKiJFJGFQi3/llnl1LH8B DdPofNqUxpbbyJckrL40IiVfQ1J8ZahYt1MB8HSb0ymLtlCkA7NQPjY17Yk+tL/Po8e6 TzsM5qnaCatbl0jduPKLtxtONx/Y203EjhKO3G44ww93xy0lsnh9TxftBKwXSmJYkeIO rYdg== 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:dkim-signature; bh=8lfUTbtt/lnQSOBZjkdp/PK/8/wp02RYgakBDUnJPyQ=; b=zCbmtKnpuk9/SoQtb9hXuXsjXwS4tNAEIxb3qOjj3mFFGzaXNufBJxp0vSeonxodMo P1HK+xLiBEhphWUthYuHD0pkB+d+OpNnt57dFwnveJIBRfkMss68lrNYnOuTExplBoFI YgAnXkHsMiwPVCBzSfl52ugwjlaaDWiWRX0o/DkDkPJ404krMCAhejuSpkVeWAcq0oYI 9WV1Lu0ZsgSSyCRQfqMdp5xoeokyEnWNq2M+MxMSXD4jq/w0tP3UDW9EU69/vBgYF2ax R9VGM1R8tDsZalrlmGgZCXSoqK0i7XwU9pw31ZyC9yaVWxIj+bMYYaOcvt5YsWORtoyR 3awQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=fjbRPVHC; 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=163.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q3-20020a170902bd8300b001890c6ff018si12904017pls.486.2022.11.29.01.36.20; Tue, 29 Nov 2022 01:36:31 -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=@163.com header.s=s110527 header.b=fjbRPVHC; 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=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230083AbiK2IQn (ORCPT + 83 others); Tue, 29 Nov 2022 03:16:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbiK2IQl (ORCPT ); Tue, 29 Nov 2022 03:16:41 -0500 Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2C98045A27 for ; Tue, 29 Nov 2022 00:16:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=8lfUT btt/lnQSOBZjkdp/PK/8/wp02RYgakBDUnJPyQ=; b=fjbRPVHCa2XGpvODDQXmj XGLvFc86RJap6evvMeBIS43ukXeKx7AddHIY0zAn5tDWkQu0OJe6jNZ40Hxfh/Fw qHuzBp3h+WHFmh4H7eow/2kZ/g2ftrSb9yiHQVpisTrRNf07Kl5TJsJEEtLnKXd1 gLtgP694y36Y0ns6EzjXtc= Received: from localhost.localdomain (unknown [36.112.3.106]) by zwqz-smtp-mta-g2-1 (Coremail) with SMTP id _____wCXDUKvv4VjdrtIAA--.23448S4; Tue, 29 Nov 2022 16:16:01 +0800 (CST) From: Jianglei Nie To: ojeda@kernel.org, andriy.shevchenko@linux.intel.com, geert+renesas@glider.be Cc: linux-kernel@vger.kernel.org, Jianglei Nie , kernel test robot Subject: [PATCH v3] auxdisplay: hd44780: Fix potential memory leak in hd44780_remove() Date: Tue, 29 Nov 2022 16:15:42 +0800 Message-Id: <20221129081542.5890-1-niejianglei2021@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _____wCXDUKvv4VjdrtIAA--.23448S4 X-Coremail-Antispam: 1Uf129KBjvJXoWrZryfAF4fuw1UAF4rZw4rAFb_yoW8JF1kpF W7WaySgr1UXryvgr1DGw1UuFWrC3W0ya4jgasFywn3u345JFyIya4rJ3s2krZxtFWfGa1I qa12qrWxJFs2yFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zR0PfJUUUUU= X-Originating-IP: [36.112.3.106] X-CM-SenderInfo: xqlhyxxdqjzvrlsqjii6rwjhhfrp/xtbBOQbIjF-PQRCQkwAAs5 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,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 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. Fixes: 718e05ed92ec ("auxdisplay: Introduce hd44780_common.[ch]") Reviewed-by: Andy Shevchenko 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..d56a5d508ccd 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 = lcd->drvdata; charlcd_unregister(lcd); + kfree(hdc->hd44780); kfree(lcd->drvdata); kfree(lcd); -- 2.25.1