Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1800667pxp; Mon, 7 Mar 2022 02:39:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzi9YPQkH1zaddcfTKYfhRecClCxbCtE7tjODslpZDw334nAfhOiugp7txDsum7OxsYsIzt X-Received: by 2002:a62:8481:0:b0:4f7:4d4:f592 with SMTP id k123-20020a628481000000b004f704d4f592mr3540496pfd.3.1646649568234; Mon, 07 Mar 2022 02:39:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646649568; cv=none; d=google.com; s=arc-20160816; b=NR2ERqfNYxI4goxWDeudMDKPe7EHQtirTj3VENoyBrS+5GDXgI7vkG2nfLvWBPoC2N fU/KdaymJ+y6vnxO3PWJKow0HNNMu6N/qpRZdYp0mIXM1P425B1uFG/tIXH70K4BL85J qnZWNwpT70ZHt6UcgaCSLBJl9VZv7dfi7WFUbQWvjezJ+M3n/bauVFbzQ9NFPn/hEx/j oF6p+7KI4EgN0OpNNydBeJe/Dw4/cnSpgXzk5r74kBENZy0+fqHFknLliZRzUpZbNf4Y PRtYXnSFqTVW0+sYH+eO7YszM6C2riG3fkqEt3xw82LkAbKD5C6/4lOby4USc/39hSaB 1Jkw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=X/GI3Lu5uyF+uWAZ6Q7bQpLaq8zJrbGBXDKJHKsNnvI=; b=DJvtQJEbZy7ppolQLO8Qnne/yZhi0wAeVeyu3d4l8ErGMcFcWghw784jpkDYe4SeP9 /o+atDPlnExecTRPxLBUoUk/rj+X2exRLhhH1ZwGo3fMLaueIQAq3CTA0a5c7ZhH0++O E/47QEoxtRzVCofdnGjKjlllDHENDtTd097igKngOc5HcSUGsBBHgOuIcKAqOC7aRnzg LLkR8VjCtQdi30UNgFIXbEP2kwe1SCuGDCyqhk/LMUOFjzv3bjlWkgQX1LAMG59zSQQ6 8by490DEGT1F6yfnqnl5Ke6kABnGrjfOya18feg4bXD1rQj/cFhJ777vyaMDDfRUDhKe Gxng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=X8ZABe0Z; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x16-20020a17090a0bd000b001bf552c46d4si464281pjd.173.2022.03.07.02.38.58; Mon, 07 Mar 2022 02:39:28 -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=@linuxfoundation.org header.s=korg header.b=X8ZABe0Z; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241938AbiCGKLD (ORCPT + 99 others); Mon, 7 Mar 2022 05:11:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240295AbiCGJus (ORCPT ); Mon, 7 Mar 2022 04:50:48 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AB6E74DDC; Mon, 7 Mar 2022 01:44:26 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 33D7360F62; Mon, 7 Mar 2022 09:44:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4688AC36AE5; Mon, 7 Mar 2022 09:44:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646259; bh=VfEIdLUz6bH6L/JeAHwklQGWBPhkXIBpMuMn3x4wokQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X8ZABe0ZSzjE5t86wqkCZ1jLSorT47nHhXUwzEU75X6oWMYeA+/SrtGM3VAf7BuCo 4Pwq8Q7jW5cisRumP3r/MaDlTp0NF1VmplHdvISDF6HmkaAFf+qWMBpylFsI3ScfUS BFC0NvlHlOz0AUlnI0RECduZ04yLCIsPKokE087Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lars Poeschel , Andy Shevchenko , Miguel Ojeda Subject: [PATCH 5.15 186/262] auxdisplay: lcd2s: Fix memory leak in ->remove() Date: Mon, 7 Mar 2022 10:18:50 +0100 Message-Id: <20220307091707.695840636@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Andy Shevchenko commit 898c0a15425a5bcaa8d44bd436eae5afd2483796 upstream. Once allocated the struct lcd2s_data is never freed. Fix the memory leak by switching to devm_kzalloc(). Fixes: 8c9108d014c5 ("auxdisplay: add a driver for lcd2s character display") Cc: Lars Poeschel Signed-off-by: Andy Shevchenko Signed-off-by: Miguel Ojeda Signed-off-by: Greg Kroah-Hartman --- drivers/auxdisplay/lcd2s.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) --- a/drivers/auxdisplay/lcd2s.c +++ b/drivers/auxdisplay/lcd2s.c @@ -298,6 +298,10 @@ static int lcd2s_i2c_probe(struct i2c_cl I2C_FUNC_SMBUS_WRITE_BLOCK_DATA)) return -EIO; + lcd2s = devm_kzalloc(&i2c->dev, sizeof(*lcd2s), GFP_KERNEL); + if (!lcd2s) + return -ENOMEM; + /* Test, if the display is responding */ err = lcd2s_i2c_smbus_write_byte(i2c, LCD2S_CMD_DISPLAY_OFF); if (err < 0) @@ -307,12 +311,6 @@ static int lcd2s_i2c_probe(struct i2c_cl if (!lcd) return -ENOMEM; - lcd2s = kzalloc(sizeof(struct lcd2s_data), GFP_KERNEL); - if (!lcd2s) { - err = -ENOMEM; - goto fail1; - } - lcd->drvdata = lcd2s; lcd2s->i2c = i2c; lcd2s->charlcd = lcd; @@ -321,24 +319,22 @@ static int lcd2s_i2c_probe(struct i2c_cl err = device_property_read_u32(&i2c->dev, "display-height-chars", &lcd->height); if (err) - goto fail2; + goto fail1; err = device_property_read_u32(&i2c->dev, "display-width-chars", &lcd->width); if (err) - goto fail2; + goto fail1; lcd->ops = &lcd2s_ops; err = charlcd_register(lcd2s->charlcd); if (err) - goto fail2; + goto fail1; i2c_set_clientdata(i2c, lcd2s); return 0; -fail2: - kfree(lcd2s); fail1: kfree(lcd); return err;