Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp305949rwe; Thu, 25 Aug 2022 00:01:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR6yRkpDnpO6l6pll9HDf26VrOLApmfMhXedUeHJEQq4+dV+5IwAGk9RAB4FT2H9a8l+tmnz X-Received: by 2002:a65:6ccc:0:b0:41e:2339:f9a7 with SMTP id g12-20020a656ccc000000b0041e2339f9a7mr2175550pgw.415.1661410889077; Thu, 25 Aug 2022 00:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661410889; cv=none; d=google.com; s=arc-20160816; b=wIpwEgplNA3eBQv68cUp2I+Ng5Dj8AU35tkkRxhftm8jNfBkxu5Y4UkG1A7R/vk60l 6yvyDLuDtaDsHPE5Ms6GtXebUaBsCyiS65pqi4gEI5gW4pdsc+p+UwRZRsyYJFAEP4gM KPN2RdrRNdM4T5hb7IeYqVn2MrUIsP26SsOEJLR0/ANVaQWyEoMPEFEwPlVIeOIPO3xr uHF6mByf3vIFngX8uZxCxVIiZnG92BbflwycOMCNwCalzIcgOS9iE6BQtpctuE0iikGB VgNcrBoF13Hx/x79R5oQWZq3/wu3FlT87aCQd554KkHu7X6GGQp7TVZr3V7+xbJ5GeTM Yx/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from:dkim-signature; bh=GGBXo1oreGaQF+5VbJ9Gt3SZ9dKLnRJrU7yLuye/fcI=; b=IIg7aOdHcEYoITlJN16ZSn0dIMGaRYAyEZjmzF9mdJzp8dS3olTvP6mXOY6i8KoDjO XH3e8KRDei7mqQFr5UDr32lXiuERYQ/R+9N6bwuZbhBOFzkqntBeowXdpjM0hpl+oImd b2bgclnB4P6XDAbET/cB4OvL/IMKP1OoXC8UZvhyAnB97IsEUxt528dncHQb5rDGKtuo pTOdPzIadF0zhYVCI+KL9BF+WsbYI//3lsitiFr/9eIb4G+9HM/rmTN2Mlol6ir6CmdS knBqqFbOgCSHeUxZU9+PugM9Ku0Hn8uwmoEHEVpdzBc7cDXhwr1LjJTWfQC0ARTKwNEY VxcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Ue0/YG6H"; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u16-20020a056a00125000b0053745aa3301si3812434pfi.14.2022.08.25.00.01.15; Thu, 25 Aug 2022 00:01:29 -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=@intel.com header.s=Intel header.b="Ue0/YG6H"; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236264AbiHYGvs (ORCPT + 99 others); Thu, 25 Aug 2022 02:51:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231133AbiHYGvp (ORCPT ); Thu, 25 Aug 2022 02:51:45 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C412AA0637 for ; Wed, 24 Aug 2022 23:51:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661410304; x=1692946304; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=oL/cDsyvaZ2AMAuLWe4mBX/p2crsIcQ5eiyX+HbuLvc=; b=Ue0/YG6HRsQ2oB2wKBCoABJ2/issO67Bq0JVmmAr9uSE/d3K9iPwKPuo i71OhokYJ/sVnMDDElXhL983ebmqGt32rIzfClYQdM+0ewuGqQaG7F5rg T/ZBRbmN9Q1C/1ED1xqO+dsMAHrPXpzV8I1hyR6Ux57ed3J+RNiJHhq0M 2GMEulEt/owjMnHskrpffrRoKQOXWXBLam4VPHSrPshXSH6YT17V+v8X8 /otmxiV6jqepEfjrLIm9LNJ7uJYsQzdShx/yoKQXdLLRdY+MHusJy1mZ5 0BK+paEnh1hvLuB5sW9McHVcNyPLO99PtmbkBUsPWBnBqtVjQFXlpoiNS Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10449"; a="320236818" X-IronPort-AV: E=Sophos;i="5.93,262,1654585200"; d="scan'208";a="320236818" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2022 23:51:44 -0700 X-IronPort-AV: E=Sophos;i="5.93,262,1654585200"; d="scan'208";a="670847183" Received: from pranavir-mobl.gar.corp.intel.com (HELO localhost) ([10.252.50.196]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2022 23:51:41 -0700 From: Jani Nikula To: Lv qian , joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, tvrtko.ursulin@linux.intel.com, airlied@linux.ie, daniel@ffwll.ch Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lv qian Subject: Re: [PATCH] drm/i915:Move the code position to reduce the number of judgments In-Reply-To: <20220825013752.120988-1-lvqian@nfschina.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20220825013752.120988-1-lvqian@nfschina.com> Date: Thu, 25 Aug 2022 09:51:39 +0300 Message-ID: <87h720izno.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Thu, 25 Aug 2022, Lv qian wrote: > If the kmalloc allocation is successful, the if is judged twice, > so I move the second judgment in to the first judgment. The code is fine as it is. BR, Jani. > > Signed-off-by: Lv qian > --- > drivers/gpu/drm/i915/i915_gpu_error.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c > index 32e92651ef7c..c8230a8beadb 100644 > --- a/drivers/gpu/drm/i915/i915_gpu_error.c > +++ b/drivers/gpu/drm/i915/i915_gpu_error.c > @@ -112,10 +112,10 @@ static bool __i915_error_grow(struct drm_i915_error_state_buf *e, size_t len) > if (!e->buf) { > e->size = PAGE_ALIGN(len + 1); > e->buf = kmalloc(e->size, GFP_KERNEL); > - } > - if (!e->buf) { > - e->err = -ENOMEM; > - return false; > + if (!e->buf) { > + e->err = -ENOMEM; > + return false; > + } > } > > return true; -- Jani Nikula, Intel Open Source Graphics Center