Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2100026rdf; Mon, 6 Nov 2023 04:57:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGd+m5W9xY7mfHBzv/tr2+fg3rRxGUXs9eejxOwW2jsct7N3VXtU0nP+mX6u/PPO39NyCx9 X-Received: by 2002:a05:6359:5e18:b0:168:cfea:2d41 with SMTP id pw24-20020a0563595e1800b00168cfea2d41mr25290645rwb.14.1699275430186; Mon, 06 Nov 2023 04:57:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699275430; cv=none; d=google.com; s=arc-20160816; b=Yn2DBrr5gzoMjI6Z/ZPwH3qTJJ4NrYF9P9DBMJ1Nrfuk+Cq/e4VlA8hRSyPtA2QIjV xSbXA1p8TsX9koZRscrirVpYIhQdqeb43E11j5+g/I8ZY8xoajXP1WpgFvmbc0rgLtsM C+T2RLUGjuAzlSB7cJ8SrV/FYUncL6dtBOfFHiQ+Y7e6W6BtVq91lEQXlKCiU3rg4+nl +WeC+9EjfUJhqw44prNLLLt9bWqW9ckyR7N008AB5ZTNtwW6dysIqEvJCTVbx5dF/OJc OfPiHmP9bahC6I35zTIDOteh/2MOhcnVO5mdWwy3JhLYNYmzju4ZYu4tXlfQgiOdpumg 0KXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zhe5NWL/Cvb/I8m+cMVnDP+/gh6uTcR57+NFLLTQAWI=; fh=vZfb3O80gXx+GWahWnKknQMjJZuXMRkYD83JzxokXDU=; b=nmoo364elYdxGkWxKwTAyle7icAxpyYrv6HlpxRbNB5NLl0j8AWcKXcpT6m5ACbTsL ZJ15vFyGoCNVbXYBgmIV680/aCuiRLfEaf7kswcvGnlIRsx7OHAxeuoNLITWvYj7TEWP gbAL/dQtfAMozzHHPQEXlNk0zVxFEPzS9r6h6m6Lz9noSs8B+NGM0l9jgD+9Jq1iW5lF BXlSwtEITZ6dz57uCu2+tIQXyTdXteYZLzIh1hk1P96O0iuk6YeiY4p+6uCzJOXlPqpI 5LyqNjmLmuDkohuKwJKQK31rnSONnRWEaJKbadXAFfWkiB8W07gz5geww18s0hFwSfLH 2N3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="2qcj/Pjk"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id k191-20020a6384c8000000b005bd42f6085fsi7266491pgd.344.2023.11.06.04.57.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 04:57:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="2qcj/Pjk"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 3CF238056C68; Mon, 6 Nov 2023 04:57:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231641AbjKFM45 (ORCPT + 99 others); Mon, 6 Nov 2023 07:56:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230514AbjKFM45 (ORCPT ); Mon, 6 Nov 2023 07:56:57 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA497A9; Mon, 6 Nov 2023 04:56:53 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E51F0C433CA; Mon, 6 Nov 2023 12:56:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1699275413; bh=RovK8HQK7N44J2KsgwsMa0xpeZZiEG8V4eFEcPd221s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=2qcj/PjkGVdh1W0Z3qTCvT3G/x7/VbhsxzKo8YosgdddchlTWctYh+LOpQILWXPGo lVxTJIKnA1BaVHHRb2QAOeaLmzBBNBQjN6fW9TuEXaPU0XP6NT+Frq4fe00HmzNtO6 wHSgXu7hA6XBItEFcf9jFLjdB5llWP0Ewxp5lbck= Date: Mon, 6 Nov 2023 13:56:50 +0100 From: Greg KH To: Florian Eckert Cc: Eckert.Florian@googlemail.com, jirislaby@kernel.org, pavel@ucw.cz, lee@kernel.org, kabel@kernel.org, u.kleine-koenig@pengutronix.de, m.brock@vanmierlo.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-leds@vger.kernel.org Subject: Re: [Patch v7 2/6] leds: ledtrig-tty: free allocated ttyname buffer on deactivate Message-ID: <2023110629-scenic-rounding-905f@gregkh> References: <20231106123415.3365732-1-fe@dev.tdt.de> <20231106123415.3365732-3-fe@dev.tdt.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231106123415.3365732-3-fe@dev.tdt.de> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 groat.vger.email 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 (groat.vger.email [0.0.0.0]); Mon, 06 Nov 2023 04:57:07 -0800 (PST) On Mon, Nov 06, 2023 at 01:34:11PM +0100, Florian Eckert wrote: > 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/ledtrig-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_classdev *led_cdev) > > cancel_delayed_work_sync(&trigger_data->dwork); > > + kfree(trigger_data->ttyname); > + tty_kref_put(trigger_data->tty); > + trigger_data->tty = NULL; > + > kfree(trigger_data); > } > > -- > 2.30.2 > This should be sent independent of your new changes please, as it is a bugfix for all kernels. thanks, greg k-h