Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp494801rdh; Thu, 23 Nov 2023 09:23:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IGkrBcXKPS38HOml8osr6AKv24RAg9lKrzGCl/IqhN7l0Y+sgfhbIuYzZ0g9+AywiiSiXXM X-Received: by 2002:a17:90b:1d8e:b0:27d:5562:7e0b with SMTP id pf14-20020a17090b1d8e00b0027d55627e0bmr176413pjb.7.1700760186746; Thu, 23 Nov 2023 09:23:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700760186; cv=none; d=google.com; s=arc-20160816; b=bBKY0PBXMOgPhLgMHZxOYemQDVrzacrMoiDQO9t1kT/FOMBTJVcg/Hu3vTo/yI1HZ2 HvuhcTfDGDa/DBrTMHva6RLIepyfXy+V7ta7y2e+NzRD1lSYkR6sl5MOm8kc6+rnGwd2 l96x5UxYSA/aR3/X9x1nVXEzEnIxidy5pPFlMeQRlJTa2KYyYtTdhg1gVRMc4hBwjps0 3GPq8oO2yZ4irdM0EWuVqXbfvz5SdXrbsu+puwvHs3UHa8YwKFUA6Q6K3bwsiZtgtNhp 6UbPOPe16bUkFVFAA89hfV+spH03kisv45tcE6cfwi9VMkLwJuoYQVaWBOxJAKlkOKD8 S9dA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9Ry091JZLGJyRPfjwBXWKh1M/vAAaF9rT4cEs5DYrFo=; fh=vZfb3O80gXx+GWahWnKknQMjJZuXMRkYD83JzxokXDU=; b=YXja6So0XeNpF/klie0avG/1YsK+b6iYsZgJ/o8ovuaOS8k+2/PCan+TDuvnmsg8AG jNCTU5bV+CCWeqVIfKQKYsNCMPlDB11Zy+a+uccs8soRaQhUPZmES439kHo6hDmpuCl8 3DH0sAgp+7HhTgO3q6h2WZf8vPFC47B03jVF8Orjsti2ilKi3ktjcQqMcmhcpsWzsS4i YN1XcjFHl/PugbxuKfZyGYV3LN4Tk9H4FbIqCjRpBU0IzDly6JDoe50XOVqQBlBr6s1d A4zHfwY3e+NwSOX/28ukl8FLwsPAkQMnjoiuM2vxOlqD7sOHCGZbUvcYhk0tNFwUQe79 tfLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yJCoIenX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id w18-20020a17090aea1200b0027769032e57si2171265pjy.52.2023.11.23.09.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 09:23:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yJCoIenX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 590A480615EE; Thu, 23 Nov 2023 09:23:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345417AbjKWRWh (ORCPT + 99 others); Thu, 23 Nov 2023 12:22:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345172AbjKWRWf (ORCPT ); Thu, 23 Nov 2023 12:22:35 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E40D69E for ; Thu, 23 Nov 2023 09:22:41 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 459C1C433CA; Thu, 23 Nov 2023 17:22:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1700760161; bh=szWvQ2xaG1q7ZyMfdMxvBZfMaG124AsSH+NxXcXWP/Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=yJCoIenXapRryyBsrj7fHwYAWpve/XSh6zQAf5HyOB1XR7sqqlrA6eU+aW0x/ZwjK 9UHpSoQTTnhcZCeIS/YYi5YKHyv/6o1LzL7vmUzRcwRg23nZvD8+V+iZNR8BnmL/34 kdFqX6LRECw7of24oaiOZLRkh/YsJWb2lROOoNP0= Date: Thu, 23 Nov 2023 14:06:28 +0000 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 v8 2/6] leds: ledtrig-tty: free allocated ttyname buffer on deactivate Message-ID: <2023112356-amount-undertook-cdb2@gregkh> References: <20231109085038.371977-1-fe@dev.tdt.de> <20231109085038.371977-3-fe@dev.tdt.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231109085038.371977-3-fe@dev.tdt.de> X-Spam-Status: No, score=0.1 required=5.0 tests=DATE_IN_PAST_03_06, 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=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Thu, 23 Nov 2023 09:23:03 -0800 (PST) On Thu, Nov 09, 2023 at 09:50:34AM +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") > Reviewed-by: Uwe Kleine-K?nig > 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; > + This should be a stand-alone patch with a proper cc: stable tag added as well so that it can be accepted now, as it is independent of this new feature you are adding. thanks, greg k-h