From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B6331D24454 for ; Thu, 10 Oct 2024 21:45:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=r3Nkp9Gj8T8WfCYEFphv8Ya8jzzbRgFqfm2KPRDOTH8=; b=SsB0ApXjwQmPB86GxwCRnKhFBV G88+uhmurTh7vCGmHsYkFW9A2mLve7O7WzT36DxK9yPX2QYoBC5spA0CNF9bPNb/J0VQuToRr8Jkq l1WcoiQJf/OePUqhyHdofB9m47xEVscRSsdyr4QleiAPiIz+qRVxAf6fC5LK8Ljc8Z+vrSrZFNqs2 6aK7BK/WJjoDe5lXltLQ7YNosJtmTTwHF3vnjh7/Q+TjtkK87Ymd8AA4v0+MNHpVdPzWTFjY+joRz 1xjGUdFrvVGjLyr5KIEV+5D1dvJcn53NLaLt5z45jViuXNp/nUyit0Jvy0wc+ZioU8NlqJ11IPmdQ GjwJrdjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sz0yN-0000000ESC4-1j6T; Thu, 10 Oct 2024 21:45:27 +0000 Received: from zeniv.linux.org.uk ([2a03:a000:7:0:5054:ff:fe1c:15ff]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sz0wy-0000000EReD-2LSe; Thu, 10 Oct 2024 21:44:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=r3Nkp9Gj8T8WfCYEFphv8Ya8jzzbRgFqfm2KPRDOTH8=; b=rkVATVo2UmA8nQ2+t7XJgA+aG/ nt5HcvlQlbiQL6mis0rnaJqY0PzW5cmZdBm5z/rBxDdWOckL+WqoNCwRVj3frX8yh7glg/9LZrmRu N9gWduCWmFEovGevkwwJRL7rpUO2JWRxwt33kbtTblOChoRt5im7x4bSCxOgRXOYD5I7kYyiLF3fL zrKR4CldEM7wgSit2LdDBGxy8FjFgMiS5iPCQ4WOu/ZqXB8X/A1lmXm2L6JuU/VOuuWao8JoW7Atd PSmL+byx8oERgJ2uPGPEeoOCnkDjwzOMBPmqGt6jWosc2kvpsRfjbUhVoOOOwa9Qw0HFCTz8sKXV/ 9N63mb0Q==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1sz0wm-00000002YMT-4BoE; Thu, 10 Oct 2024 21:43:49 +0000 Date: Thu, 10 Oct 2024 22:43:48 +0100 From: Al Viro To: Javier Carrasco Cc: Dmitry Torokhov , Matthias Brugger , AngeloGioacchino Del Regno , Hans de Goede , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Florian Fainelli , Broadcom internal kernel review list , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-rpi-kernel@lists.infradead.org Subject: Re: [PATCH 06/10] Input: sparcspkr - use cleanup facility for device_node Message-ID: <20241010214348.GD4017910@ZenIV> References: <20241010-input_automate_of_node_put-v1-0-ebc62138fbf8@gmail.com> <20241010-input_automate_of_node_put-v1-6-ebc62138fbf8@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241010-input_automate_of_node_put-v1-6-ebc62138fbf8@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_144400_655744_C4A16F6E X-CRM114-Status: GOOD ( 14.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Oct 10, 2024 at 11:25:56PM +0200, Javier Carrasco wrote: > > diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c > index 20020cbc0752..bb1c732c8f95 100644 > --- a/drivers/input/misc/sparcspkr.c > +++ b/drivers/input/misc/sparcspkr.c > @@ -188,7 +188,6 @@ static int bbc_beep_probe(struct platform_device *op) > { > struct sparcspkr_state *state; > struct bbc_beep_info *info; > - struct device_node *dp; > int err = -ENOMEM; > > state = kzalloc(sizeof(*state), GFP_KERNEL); > @@ -199,14 +198,13 @@ static int bbc_beep_probe(struct platform_device *op) > state->event = bbc_spkr_event; > spin_lock_init(&state->lock); > > - dp = of_find_node_by_path("/"); > err = -ENODEV; > + struct device_node *dp __free(device_node) = of_find_node_by_path("/"); > if (!dp) > goto out_free; Sigh... See that state = kzalloc(sizeof(*state), GFP_KERNEL); if (!state) goto out_err; above? IOW, this will quietly generate broken code if built with gcc (and refuse to compile with clang). Yeah, this one is trivially fixed (return -ENOMEM instead of a goto), but... __cleanup() can be useful, but it's really *not* safe for blind use; you need to watch out for changed scopes (harmless in case of device_node) and for gotos (broken here).