Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp495163rwb; Fri, 4 Aug 2023 16:57:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEh9UE5ZIAbiO7i3H3XapdigayJHch8ReicvQ+bBTk2UMNAonNUDAr51JplTLCgKlrZuMuf X-Received: by 2002:a05:620a:2a08:b0:766:fc47:fa00 with SMTP id o8-20020a05620a2a0800b00766fc47fa00mr4701614qkp.29.1691193422726; Fri, 04 Aug 2023 16:57:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691193422; cv=none; d=google.com; s=arc-20160816; b=QbSbkfvsaa9Fhr2g+UMLLGxwXpStFVtqPfkm0FnW7Y7GmfifamEm3NldE54mjTIvlP bL+0DXFW07nQElfNAQmKnnccvwQicrKEnJm/KnssFapAxeuPKpGV6ylnMkGMdIopD+fK pm+k3SulCVM0dpd5CJMHbLF8VGaZ7/K6vDMAqUeOSQdJKTHNzrtUXfTzmYisyUUox9Va rfpLE5KxTQBKB0hTmJdcCLIp4CukRAw5VohGqLrDBKwrhwyOG9BT+IIKSSVeHzYj3Tm8 opTnJ9ZaG2TSYpC+0BsIC+9djV2n2kkD+PvIhHTkWInjQ5+qTPE3wm7i6Ac3CHKYilBT syPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=8dhh3hhtVqZDNnQrVI+Txd19vydqDfttDvdBJ3HpMz0=; fh=wdtxivixFPjSxi2erThcngYH0p46FeeeA31wKYDVo0I=; b=pcN3NhnTO8wJP46sDqw89NuABrGstSitXJgC1eT15tErBRtbZ+mQbkWVkkUmQe0Wm1 Agb6ZgFTO1/gl9Xh5ZjdOohYmUwAAPnlTDPcdnvx8DS8m6+UJpyyif/JgS1AdnS3pfjZ O+RBBtx3a380fql4LimWlaNkglBj6fiwdbpse8+YE4RZdrgGsfA3EiyBDJaD1g6H/wKf rurmZjHPMgPtI6qwJkwvxan0nT7EkPWm3GsLjvbldnsuSIIjPG39wN2sab+60F/pBBzM M0J3hT8PbPzMXg54YGy5C1cnUsgU4cgmfr27fzhfkNo+Zqie7sNYu94fE2Q/EMA/TXIc Bh+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jkCQ1DAQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jy16-20020a17090342d000b001b89f653005si2381169plb.394.2023.08.04.16.56.51; Fri, 04 Aug 2023 16:57:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jkCQ1DAQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229839AbjHDWYI (ORCPT + 99 others); Fri, 4 Aug 2023 18:24:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229582AbjHDWYG (ORCPT ); Fri, 4 Aug 2023 18:24:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 149A61704 for ; Fri, 4 Aug 2023 15:24:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A74B362137 for ; Fri, 4 Aug 2023 22:24:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DA61C433C7; Fri, 4 Aug 2023 22:24:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691187845; bh=Fnt/9iWd4ZQ9T3UfZDA89bmlPIEv0uD6+RSSiVd+tZs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jkCQ1DAQ+8+kf+CVwwY5QyM5J3y9O+DXJmATvP5CVpPkfPwfkcgjkldMgnYP5/RAv 4aezNy43WzjOW8AgIO4YF2XJfLozeVUhIGn12OCVeEXLXSiAN29Bvdqn/2HPHHQotv ENF6xfgG50vA1KWBk5SuRnvhkhQhxQ9B2SqDNVAtGjB3+zW4M491vgUCUr1LPWIziP d0o+4XpI24HtcYjc/7M+U+b4xfCA8BKgjAPpyC0amzx8ePdD1wr9ZSc8qOqGR0bhx/ m38dZREAabj9CZLwo7x+1emVrEHHvQebrY5vWVtcaFUeezyLM8IQZcILarRVe2p9hu bPse2YmLMC9wQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qS3DG-002Mjz-Kf; Fri, 04 Aug 2023 23:24:02 +0100 Date: Fri, 04 Aug 2023 23:24:02 +0100 Message-ID: <86cz025tvh.wl-maz@kernel.org> From: Marc Zyngier To: Andy Shevchenko Cc: Johan Hovold , linux-kernel@vger.kernel.org, Thomas Gleixner Subject: Re: [PATCH v1 1/1] irqdomain: Refactor error path in __irq_domain_alloc_fwnode() In-Reply-To: References: <20230804164932.40582-1-andriy.shevchenko@linux.intel.com> <84f2ea9ee0c08c8826c0f26c4a6291c9@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: andriy.shevchenko@linux.intel.com, johan+linaro@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 04 Aug 2023 21:12:11 +0100, Andy Shevchenko wrote: > > On Fri, Aug 04, 2023 at 06:33:07PM +0100, Marc Zyngier wrote: > > On 2023-08-04 17:49, Andy Shevchenko wrote: > > > First of all, there is no need to call kasprintf() if the previous > > > allocation failed. Second, there is no need to call for kfree() > > > when we know that its parameter is NULL. Refactor the code accordingly. > > ... > > > > n = kasprintf(GFP_KERNEL, "irqchip@%pa", pa); > > > break; > > > } > > > - > > > - if (!fwid || !n) { > > > + if (!n) { > > > kfree(fwid); > > > - kfree(n); > > > return NULL; > > > } > > > > What are you trying to fix? > > I'm not trying to fix anything (there is no such statement from me), > but I would think of some micro-optimization (speedup boot for > unnoticeable time? Dunno.). Error handling paths rarely qualify as an optimisation. > > > We have a common error handling path, which makes it easy to > > track the memory management. I don't think this sort of bike > > shedding adds much to the maintainability of this code. > > Your call, of course, but I not often see in the kernel two or three attempts > to allocate some memory and have grouped check for the failure. Things like this[1]? Well, this is a pattern I use often enough. Maybe it isn't everybody's taste, but it suits me. M. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/irqchip/irq-gic-v3-its.c#n3438 -- Without deviation from the norm, progress is not possible.