Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp14516103rwb; Mon, 28 Nov 2022 01:51:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf5/SpReQfKDkxiX0Rp04jWxD1lreb8ImhXs21xgssTk8mUmC5OZkOB0wgbXgGbK8ZtBpf8R X-Received: by 2002:a63:1a52:0:b0:464:3985:3c63 with SMTP id a18-20020a631a52000000b0046439853c63mr26982203pgm.141.1669629119461; Mon, 28 Nov 2022 01:51:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669629119; cv=none; d=google.com; s=arc-20160816; b=M/Ol9SCLjQebLOvylj4Rhz4D78vydnpj2xhTVEbbfbfwcyKRwuetlOnijeBvh7GdEi UIGnMpk4HFMfBCEHvKHzni/LXhkOkdwcAguqhpxU/MKJAdasgxj1JenUt3GGVSQnKZjQ 4ZF15+Z/ljzX1o7vjwWbKN87VkhDqcDeSpcsuZf4/6XtiEamptNfPmRAbhRMsccodJaU 4c7pBPRyKMnZeWGnvRdvnNXA4PqwIJTyL0w7lX7A/PBxzOm8Q+6i4lk87pTp/SsMRo/8 gXBZXxKJZQCorq6D6ZRwrSIbLEKcKG56AbeRl3l+1x5Z+eF8daIFJ6+Alx6z0zgR72Xb JA7w== 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=Vdt8u9zvqOSP/nM0l2OSHGSUIYvnzovrjlUR+LN6Jf8=; b=he9FZOxRmFLvG37r6ysTmJq3HBMoXwZPOVGBzbCtfgImxHgkb17nVdFEehoItlqblP M2y4zvUoIuXCW1otBUfiTUrzB+2KT33/wi8SZcxloFeYhfBaR+opP9zztZ4kKJI4+C+Y cwp7kVo/ZCBAZf3rcXx62Uv0z/zhXalR4iZ7Q+Db53uPK/CvAPZTxBRvN1jW5EugxDh0 UOpTR68bK5472ExdstK7G6DNZbDPJ6Zr4OqiAKaBp2btPzH4NidhlSuypH6o8WFEao38 u3tdrzXDeXhI1NpwZj2tCIAsSNU0tZIbNxVRCCVgSMiwKVTokrfOorR+w4vMHa24GU/t RDAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=dVqpo5LH; 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 li17-20020a17090b48d100b00218f9c0cfbesi10249649pjb.169.2022.11.28.01.51.48; Mon, 28 Nov 2022 01:51:59 -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=dVqpo5LH; 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 S229823AbiK1JAW (ORCPT + 83 others); Mon, 28 Nov 2022 04:00:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229773AbiK1JAR (ORCPT ); Mon, 28 Nov 2022 04:00:17 -0500 X-Greylist: delayed 914 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 28 Nov 2022 01:00:16 PST Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2CB017640 for ; Mon, 28 Nov 2022 01:00:15 -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=Vdt8u 9zvqOSP/nM0l2OSHGSUIYvnzovrjlUR+LN6Jf8=; b=dVqpo5LHZVCPlcj8iE613 EmZ71CcfnjK2UKadsNx4IwzU+15LXoQxa776c4Ka/Z1wZksBzJYzVJ0L+gzJcjwU L0tV3tJPoi2D1d5NNltHCFGRQgH41DQ3QhiWgHcTSjphw5zUi31WeqFkwQ3aiqOk b6rBG+qUjM7MblUeAnk3VQ= Received: from localhost.localdomain (unknown [36.112.3.106]) by zwqz-smtp-mta-g0-4 (Coremail) with SMTP id _____wAHh0_mdIRjPgjhAA--.56577S4; Mon, 28 Nov 2022 16:44:34 +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 v2] auxdisplay: hd44780: Fix potential memory leak in hd44780_remove() Date: Mon, 28 Nov 2022 16:44:21 +0800 Message-Id: <20221128084421.8626-1-niejianglei2021@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _____wAHh0_mdIRjPgjhAA--.56577S4 X-Coremail-Antispam: 1Uf129KBjvJXoWrZryfAF4fuw1UAF4rZw4rAFb_yoW8Jr43pF sxWFWfKr4UXr1vgw1DGw1UuFWrC3W0ya4jg3s2kws3Z345JF1Iva48J3sFkrW3tFWfGa12 qa12qrWfJFs2qFUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zR0PfJUUUUU= X-Originating-IP: [36.112.3.106] X-CM-SenderInfo: xqlhyxxdqjzvrlsqjii6rwjhhfrp/1tbiWxfHjGI0XNaN-wAAsp 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: 41c8d0adf3c4 ("auxdisplay: hd44780: Fix memory leak on ->remove()") 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; charlcd_unregister(lcd); + kfree(hdc->hd44780); kfree(lcd->drvdata); kfree(lcd); -- 2.25.1