Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2149671rdf; Mon, 6 Nov 2023 06:12:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IG5oTvs+kA36wEP74SpbL+qUtDw90ZdmM348f/mKuyvwuIcCYwin+HRbzfo9uEWiRbeCuWh X-Received: by 2002:a05:6359:2881:b0:168:fdec:427b with SMTP id qa1-20020a056359288100b00168fdec427bmr22823589rwb.18.1699279961424; Mon, 06 Nov 2023 06:12:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699279961; cv=none; d=google.com; s=arc-20160816; b=Es6bfbObHoDp45cw2XCLFuxmAqAHP/wgLPWkLMQNOaKS5aVghzlaol0rX3o9t7o8Bd 8B/1F29fGZatlwf/wn5xTXoW5nxQfmkak/Y5XYxsTiCWl1Nr0BwBFJddetCcSlQUd2Nw +Vg0n43YM/elhlyfTtTHy8h28s2+KYE99F+WoUyBgqj3q8SiKS2k7vP7wCmfCQZy30d4 X+wADhqtpEzbNnrDyRh+0cVmI4Z9rseqwqcLCUEWOlxj8Lyc1DGZeq3sxPawnC97Cpbg qbfZ7igKxkgE8bf6P8pZhecqn4yS3oyk6e4fQQ0EZfJryq0gKIGMDuyIjQhpYusYWfq6 lLyQ== 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; bh=GIIlVBAcMxtGt1EfxtIteMzl25F6hmuQpxAEnlA33ms=; fh=2OSeo/8TDcFyJQEse8QfWUOgffOUeTBI3abptknu/uw=; b=p/PorBcW7ZY+UKUzBd+4ZfzYj9ARD9LmpSxsB23QAjcgJ4ki7OZKkV0sdxBaIid+K9 gt3UutUV2yuBPSrmjLKPVObh8lEvzSctD+73EuJwzDjU7DWNW3WJwCYyQZiN1qNV8Jlj 3IvU5zfWNXraOu2HbAg1NQH8k9c9ztUIz5mL+X1CjwYxJxv7yboJgoJXqJSOzxa+TCS2 3HeAaWcQVj0qUA7/ckvtr3U72LOJ+4xGu/P0ESW4w8WppT+cXqHhBJ2P7p8L8n+ZTWb1 V2/FRolMI7gUO5WR8vGJvBJneeWnjf/C2HOMFozQysCmLblQ0qE8l4aaJZrDRHar6RPb J0lQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id g10-20020a63110a000000b005b9302f3e47si7860034pgl.3.2023.11.06.06.12.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 06:12:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id A1FC580BA97E; Mon, 6 Nov 2023 06:12:34 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230146AbjKFOMV (ORCPT + 99 others); Mon, 6 Nov 2023 09:12:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjKFOMU (ORCPT ); Mon, 6 Nov 2023 09:12:20 -0500 Received: from mxout70.expurgate.net (mxout70.expurgate.net [194.37.255.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06083DF; Mon, 6 Nov 2023 06:12:16 -0800 (PST) Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.92) (envelope-from ) id 1r00Kp-00EZJv-Cp; Mon, 06 Nov 2023 15:12:11 +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 1r00Ko-000oci-J8; Mon, 06 Nov 2023 15:12:10 +0100 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id 11E4F240049; Mon, 6 Nov 2023 15:12:10 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id 72912240040; Mon, 6 Nov 2023 15:12:09 +0100 (CET) Received: from localhost.localdomain (unknown [10.2.3.40]) by mail.dev.tdt.de (Postfix) with ESMTPSA id F412022029; Mon, 6 Nov 2023 15:12:08 +0100 (CET) From: Florian Eckert To: Eckert.Florian@googlemail.com, pavel@ucw.cz, lee@kernel.org, kabel@kernel.org, gregkh@linuxfoundation.org, u.kleine-koenig@pengutronix.de Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [Patch v2] leds: ledtrig-tty: free allocated ttyname buffer on deactivate Date: Mon, 6 Nov 2023 15:12:05 +0100 Message-ID: <20231106141205.3376954-1-fe@dev.tdt.de> X-Mailer: git-send-email 2.30.2 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 agentk.vger.email Content-Transfer-Encoding: quoted-printable X-purgate: clean X-purgate-ID: 151534::1699279931-5764D018-27B6FD65/0/0 X-purgate-type: clean 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 (agentk.vger.email [0.0.0.0]); Mon, 06 Nov 2023 06:12:34 -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. Cc: stable@vger.kernel.org Fixes: fd4a641ac88f ("leds: trigger: implement a tty trigger") Signed-off-by: Florian Eckert --- v1 -> v2: Add Cc: tag 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