Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp34991lqn; Thu, 11 Apr 2024 12:56:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUkx9kr7sFVJqOMbL+RF/PCJMEC5toO1FHhjIrurxSBjrvAeKEVgdOPEa2QMt+Zy729/g0PJ0eERUJMPGZeU2Cltoq+a+hmppQxzlKXOw== X-Google-Smtp-Source: AGHT+IEQmLFnM434JzOFvEDxdnggksl0ASQthw1kr4fl6rzeUlzv3gVxbR3dYL7XCx1XvrpfxfRU X-Received: by 2002:a17:906:2bcb:b0:a4a:850f:28fd with SMTP id n11-20020a1709062bcb00b00a4a850f28fdmr507681ejg.29.1712865381302; Thu, 11 Apr 2024 12:56:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712865381; cv=pass; d=google.com; s=arc-20160816; b=qHOSAC25qT1VyROtpEU0qbJfqxU832kOnSCfQu9uzwSus0+h49wbuY1eKdapARPLKp SUL6JfTKB/Q00vAe0vhC4WrCCBz847aBHEss91jKSlSC/LucxdW4ctZlRz64VBnpo2gz dQshA4fTsNIAOwfaZfwyflMWESE/smaZJXk4m7YOdAlyKNME/6Z+htuttFgLcIz/NBEV QjwljR5ZaF4CWTRdWzQYS1HkhA5q+sZRgY19Wv0OPsyevoLVignAMFwFSgYvJpimsDJH fNidRUK8PkRkbzRn1YKtvYTxmlOc6UQ2HH/hgt9RZwvMKXzQGEhb/U35KFf95DOvPVFS jRtQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=8sOTjpfXBn1Eh0uSByLQp3Sb1BIP0exqSFp5at+Sydk=; fh=d2uLX7C8aVXfGf+f034rZJIVKZHDtC7m2ff1sxC8oPI=; b=eGZ9UGwozbvFBtuF25CJoVpTOMOdPIZH55/eYYvgk+uPbmflQ3Lfjf89Vcy4q3jPEi R7RqdLsasN0Ql+0PfMjdD0b191ZKm+lZbUJdEpNdt6mcrQJ5T++MdufcOXIr5zS4sjMs DPpzU+D6eZ0tHCzoOQPZ1LxjgaltYEqEvBvbHRF0faw03T9FeLuQggcD1R43IpUu9+Uo IJdP5V+TUDwh56IO01f9wI+o3QDA8GnKGNJTPGt8el4vMSHW5EtSBGxlBQQVO463bun7 usv2GMp0hJqBGjEq2vEfDpcT3ohwfhzYSUoJ8d/1lrwGZZmi/5LPCRQP6ipv5Twtl07s zmUA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Pkslds6r; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-141458-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141458-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id d15-20020a170906174f00b00a51e9bb5ceasi981267eje.53.2024.04.11.12.56.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 12:56:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141458-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Pkslds6r; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-141458-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141458-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AB1081F29502 for ; Thu, 11 Apr 2024 18:37:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E149213A25F; Thu, 11 Apr 2024 18:11:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Pkslds6r" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DE6A13A248; Thu, 11 Apr 2024 18:11:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712859100; cv=none; b=gzU/LJYMSIWjvKi3yBN5bq1FJ5waIcHCZ1KiOFwIKdQgopAL+/9htDgy7RxYQlhBz8qBmDhe2CgIFUNml9mW8NAw8H9agtBP03WuNLYg1X3sc38bq60QDv0mG7cShS0Qfj3ukIHuCxvVb/vcMQa50Th85P/2TvlRlcSDMEYSTxs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712859100; c=relaxed/simple; bh=6PD3j62MZIhS1PTwrJR+fB5FOccOx8hNCngLSnkhUUM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gLMkAAf8EFPt3g0CmBA+kZaAwLh4/FB9PezoucqmDP7NNU6YeDd3Smj/aBRdkapv28CYYnH4V4Ekpr0Ediu6e82jdv2IY3YpHAAmTvfLBGajnvMOAtkcV9u/tgVmN1Hp//LPsHAf5Tlf4rA1+hsxVtrStszgDIn261WBP3HSivE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Pkslds6r; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FF53C072AA; Thu, 11 Apr 2024 18:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712859099; bh=6PD3j62MZIhS1PTwrJR+fB5FOccOx8hNCngLSnkhUUM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Pkslds6rM2DQ0uj78jhCYHoC3+F9IXK8RCTl8maGsIdCcCfwsycdXHUzmvFi/EEHQ VDSsNkmQpbGmBxme6A8UVgEEB149FZUp7oxCQYyBMAUuABd135KFCg1/Fm2f/S5hw/ S2lBQrPLx5x3J7Z12Rrwqaq176a87h1io9r95HWo= Date: Thu, 11 Apr 2024 20:11:36 +0200 From: Greg KH To: Roman Storozhenko Cc: jirislaby@kernel.org, Julia.Lawall@inria.fr, skhan@linuxfoundation.org, javier.carrasco.cruz@gmail.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: Re: [PATCH] sysrq: Auto release device node using __free attribute Message-ID: <2024041111-tummy-boil-a6aa@gregkh> References: <20240411180256.61001-1-romeusmeister@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240411180256.61001-1-romeusmeister@gmail.com> On Thu, Apr 11, 2024 at 08:02:56PM +0200, Roman Storozhenko wrote: > Add a cleanup function attribute '__free(device_node)' to the device node > pointer initialization statement and remove the pairing cleanup function > call of 'of_node_put' at the end of the function. > The '_free()' attrubute is introduced by scope-based resource management > in-kernel framework implemented in 'cleanup.h'. A pointer marked with > '__free()' attribute makes a compiler insert a cleanup function call > to the places where the pointer goes out of the scope. This feature > allows to get rid of manual cleanup function calls. > > Suggested-by: Julia.Lawall > Signed-off-by: Roman Storozhenko > --- > This patch targets the next tree: > tree: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git > tag: next-20240411 > --- > drivers/tty/sysrq.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c > index 02217e3c916b..1d1261f618c0 100644 > --- a/drivers/tty/sysrq.c > +++ b/drivers/tty/sysrq.c > @@ -758,11 +758,12 @@ static void sysrq_detect_reset_sequence(struct sysrq_state *state, > static void sysrq_of_get_keyreset_config(void) > { > u32 key; > - struct device_node *np; > struct property *prop; > const __be32 *p; > > - np = of_find_node_by_path("/chosen/linux,sysrq-reset-seq"); > + struct device_node *np __free(device_node) = > + of_find_node_by_path("/chosen/linux,sysrq-reset-seq"); > + > if (!np) { > pr_debug("No sysrq node found"); > return; > @@ -781,8 +782,6 @@ static void sysrq_of_get_keyreset_config(void) > > /* Get reset timeout if any. */ > of_property_read_u32(np, "timeout-ms", &sysrq_reset_downtime_ms); > - > - of_node_put(np); > } > #else > static void sysrq_of_get_keyreset_config(void) Also, this change really makes no sense at all, the pointer never goes out of scope except when the function is over, at the bottom. So why make this complex change at all for no benefit? In other words, properly understand the change you are making and only make it if it actually makes sense. It does not make any sense here, right? thanks, greg k-h