Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2088920rdf; Mon, 6 Nov 2023 04:36:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IEuhkkPYYgH4x/JbLf1U4Q88pSfORAiQOSuczX497Hf4maQTu4GAkbcCh4LmA4doOZvFzTB X-Received: by 2002:a05:6a20:3ca7:b0:14c:a2e1:65ec with SMTP id b39-20020a056a203ca700b0014ca2e165ecmr37965279pzj.38.1699274185334; Mon, 06 Nov 2023 04:36:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699274185; cv=none; d=google.com; s=arc-20160816; b=Y+LrBTne3VSsUc+NMUQRj0QJUtP6B+i+x9uYS8noSWNu99eppTgY2znjfKLjElxhVu L8iDKdAeVA6JuZKPrDV+W3uoJibe8jrZ35dTEo4XiuQDeIf27KRewxADXmnZu6lcwjqY E1Q6vfWDrh6QIfxsm/9cRu/ns6LQul9ZGw2n+P8mj5ReUfrGotIhBhagJYIT2DUoYqrn fNoe82tiZ5gJbZGSAIXR5qqC0lA9fawGXBzibpqQl0iBDBeLEhOFYXrxleiU4Ho0M30C Fq/O7WaVDX5tg/FbZWuuCKfi11MHhfVjUfLLFhnMVDr+nCFHXITqP2tTc1oIaUoEcTvw tJgQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=XsadEFR7fHY4Ii1CdJkxJV8fHRekr7q55qmqeK84GAs=; fh=IgHQrLPsdr1hVJosYJHJpHjj5JtHhVjUE8MVksLn+5s=; b=b7RM5/0awaJP5CTGiMqFz5GiW/rsUNf5Hh6YQbjdXA5/WdsZEs9e3sM8ARhA7+jURz m4O1Yv3H8pVPcdqnUCos4qs3SZL3N8Si8lC9o81WnWJJU8ukYab/KHjvT17ebXF65YrL OC3V/Fxr/wBkb0siKwJ1/gV/ubHBXT/c0VlWXiR6Rv8RHyaI73ECpkMW4h2CH54oDK/7 QyKAejoUcd4O1OsRa5rfC0o74zT6IYsyvRfW6A1QekFz/9jGwgWuCFdlkEZyK6Io0qmA 8+mj3LAbYyekG4K+Grr2XYKc3SM4jEViuoigah6ZhQg9En5gxk/q76QsF0Z6EMn2cWdv +bug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id v19-20020a056a00149300b0068beee4922csi8528622pfu.23.2023.11.06.04.36.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 04:36:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2E0D280A14A0; Mon, 6 Nov 2023 04:35:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231764AbjKFMev (ORCPT + 99 others); Mon, 6 Nov 2023 07:34:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231648AbjKFMem (ORCPT ); Mon, 6 Nov 2023 07:34:42 -0500 Received: from mxout70.expurgate.net (mxout70.expurgate.net [194.37.255.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77D8BB7; Mon, 6 Nov 2023 04:34:39 -0800 (PST) Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.92) (envelope-from ) id 1qzyoG-00GOPh-VV; Mon, 06 Nov 2023 13:34:29 +0100 Received: from [195.243.126.94] (helo=securemail.tdt.de) by relay.expurgate.net with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qzyoG-00HTwR-2T; Mon, 06 Nov 2023 13:34:28 +0100 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id ABAAF24004B; Mon, 6 Nov 2023 13:34:27 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id 0589224004D; Mon, 6 Nov 2023 13:34:27 +0100 (CET) Received: from localhost.localdomain (unknown [10.2.3.40]) by mail.dev.tdt.de (Postfix) with ESMTPSA id C858B2225B; Mon, 6 Nov 2023 13:34:26 +0100 (CET) From: Florian Eckert To: Eckert.Florian@googlemail.com, gregkh@linuxfoundation.org, jirislaby@kernel.org, pavel@ucw.cz, lee@kernel.org, kabel@kernel.org, u.kleine-koenig@pengutronix.de, m.brock@vanmierlo.com Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-leds@vger.kernel.org Subject: [Patch v7 2/6] leds: ledtrig-tty: free allocated ttyname buffer on deactivate Date: Mon, 6 Nov 2023 13:34:11 +0100 Message-ID: <20231106123415.3365732-3-fe@dev.tdt.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231106123415.3365732-1-fe@dev.tdt.de> References: <20231106123415.3365732-1-fe@dev.tdt.de> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Content-Transfer-Encoding: quoted-printable X-purgate-type: clean X-purgate: clean X-purgate-ID: 151534::1699274068-066056AA-98EB4578/0/0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 06 Nov 2023 04:35:31 -0800 (PST) The ttyname buffer for the ledtrig_tty_data struct is allocated in the sysfs ttyname_store() function. This buffer must be released on trigger deactivation. This was missing and is thus a memory leak. While we are at it, the tty handler in the ledtrig_tty_data struct should also be returned in case of the trigger deactivation call. Fixes: fd4a641ac88f ("leds: trigger: implement a tty trigger") Signed-off-by: Florian Eckert --- drivers/leds/trigger/ledtrig-tty.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/leds/trigger/ledtrig-tty.c b/drivers/leds/trigger/le= dtrig-tty.c index 8ae0d2d284af..3e69a7bde928 100644 --- a/drivers/leds/trigger/ledtrig-tty.c +++ b/drivers/leds/trigger/ledtrig-tty.c @@ -168,6 +168,10 @@ static void ledtrig_tty_deactivate(struct led_classd= ev *led_cdev) =20 cancel_delayed_work_sync(&trigger_data->dwork); =20 + kfree(trigger_data->ttyname); + tty_kref_put(trigger_data->tty); + trigger_data->tty =3D NULL; + kfree(trigger_data); } =20 --=20 2.30.2