Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp198477rwb; Fri, 4 Aug 2023 11:11:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGaJei9LSE2G4rSv9W6V6h0kcPtzJL/1qzsLNndNsR44I1FI240eviw2hRoa1b651A5C301 X-Received: by 2002:a05:6a00:23c6:b0:687:903a:beb9 with SMTP id g6-20020a056a0023c600b00687903abeb9mr529796pfc.9.1691172688188; Fri, 04 Aug 2023 11:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691172688; cv=none; d=google.com; s=arc-20160816; b=DA5/xXUykcnuiHTCaS2lPpzUJLT6tKgenGUN6wP+a6wlgMwFv7Nq/gJuCt+QIUpcnA VPD1ogx4sp7Hq2BF1/hWx9rKyCseIVng3oGlhP3sFzxJnAC4OR1nHrD2vUdSB97wg8ov HGluF+1LsGGUwmIoulgN4FPIELjW8keRWJ/Efs9/LkMrAjXieUYntJCEBpyZHoK9Rt5X 2ZbbLMR0sNBXgVI7QRATm74fhKKM07xFb+FpdZn2Vnt8B7QJOqOijmpZ8o9ARtRLitG5 3fCpiL4Ll6EtIuBovXVWzDWTpYZ3zgul22I6E/Y0IuaCjrSxSEBrW6uba+EcBRYsnQWF JebA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:user-agent :references:in-reply-to:subject:cc:to:from:date:mime-version :dkim-signature; bh=KDAHpsvUnF6Orx66ScnDuuzPffYU/uK2CLAnmdUvVzk=; fh=wdtxivixFPjSxi2erThcngYH0p46FeeeA31wKYDVo0I=; b=A3m1t38tGfuQXIdcOTp4bJ7/ZDx+u7+8lau99eLgiL52lwsAsO9K1mV3kJMUmjjNKF /RDJEKNHBCHtelICpDloraWNH8N/Fiwh+YLZF++UKZjmlOvAq2klUEbeF5JiJDNcH3WC u7NAyu4yKgdiGnn8MpQLYx4qTcSLFvDywN31Kqu2ENpnETH8tQV5SOoJAT+mcNWt3ff+ /o3ziSKoOtd4pbEvTmCxdtywurAIsEn0IqnVk1QX+hxDSoSBwE2SEAWsX5M7JNyg8FQt glRiu1+esBk0GIgaKbHA+HrJeiMeqOS6k49T7GABV3XO2vs08ZWodhQfjbLpKH0Rfwm1 sbUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J6YaTsD6; 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 28-20020a63155c000000b0055c7da0216dsi1987374pgv.635.2023.08.04.11.11.14; Fri, 04 Aug 2023 11:11:28 -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=J6YaTsD6; 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 S232336AbjHDRdP (ORCPT + 99 others); Fri, 4 Aug 2023 13:33:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232327AbjHDRdN (ORCPT ); Fri, 4 Aug 2023 13:33:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2724EA9 for ; Fri, 4 Aug 2023 10:33:11 -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 B40DA620D1 for ; Fri, 4 Aug 2023 17:33:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 173C7C433C7; Fri, 4 Aug 2023 17:33:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691170390; bh=dnWlwvaPnL16cTC8ijLOxs1uggOtQe0XY2hrk+YTBGI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=J6YaTsD6QPeFmQ30poWaU6dNgzYSBjx3IKA0/HcHkABClRo6J9SyxI69icKW1js3x GqiMHQYoAU+u3EPGHczjoozhpeoF07JeTtKIfiEdTvyEUKcQw2DJhPoXKSsOJ2Izjj MztWGCM6iQHiz5vFRiL0nLl7PjM+8uNejhk66FR1DciMO9saJQujtAeQwKQNH2mGLJ 7ryaySjgBoRw2du7fSzPm7aeEdH4AAAOI/PizH6ztoytyGzF6R2Ln3s7AD0M3I0vZg c7ax46DIbU/n7wytdDJshHHSf7zQhfu9ABLq9U8JmLAcLJ79E+t+erqC8c9KiY9hxL RVEjZr3XTBMGA== Received: from disco-boy.misterjones.org ([217.182.43.188] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qRyfj-002Ix4-Ij; Fri, 04 Aug 2023 18:33:07 +0100 MIME-Version: 1.0 Date: Fri, 04 Aug 2023 18:33:07 +0100 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: <20230804164932.40582-1-andriy.shevchenko@linux.intel.com> References: <20230804164932.40582-1-andriy.shevchenko@linux.intel.com> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <84f2ea9ee0c08c8826c0f26c4a6291c9@kernel.org> X-Sender: maz@kernel.org Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 217.182.43.188 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=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 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. > > Signed-off-by: Andy Shevchenko > --- > kernel/irq/irqdomain.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c > index 0bdef4fe925b..d2bbba46c808 100644 > --- a/kernel/irq/irqdomain.c > +++ b/kernel/irq/irqdomain.c > @@ -81,6 +81,8 @@ struct fwnode_handle > *__irq_domain_alloc_fwnode(unsigned int type, int id, > char *n; > > fwid = kzalloc(sizeof(*fwid), GFP_KERNEL); > + if (!fwid) > + return NULL; > > switch (type) { > case IRQCHIP_FWNODE_NAMED: > @@ -93,10 +95,8 @@ struct fwnode_handle > *__irq_domain_alloc_fwnode(unsigned int type, int id, > 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? 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. Now if you have spotted an actual bug, I'm all ears.   M. -- Jazz is not dead. It just smells funny...