Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp123022rwe; Wed, 24 Aug 2022 18:42:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR4kzl9C23YY4XmI4c+paxlbDM5+KayxZxTSdKMXFe7Wk/DOJZcuGbeZssIKqCxthtg+OKhm X-Received: by 2002:a17:902:d2d1:b0:172:e5f6:24b with SMTP id n17-20020a170902d2d100b00172e5f6024bmr1614175plc.45.1661391778237; Wed, 24 Aug 2022 18:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661391778; cv=none; d=google.com; s=arc-20160816; b=oA6rbpM9KFTBfCzLx3ej4ddH125uYW8PNeV0xAk0aGz7sLvDVrRU/uegnMPqiCB91T lPfbkhELnFzZ8mMdkJ50zqPXN0CmFh8wID+DBNH4ceiVitJIw9V6gXqRj/Wp6XI3+8mW 1QxG4Qja8NwyMOTyp+aPHs2KmbRVozV9l4w9YZjQmvL9K0g9qdTd3ZUnBSAkqet8+z3N oTPdneXYNKVxbkTUPHf+lGg6qDLS5TmITvPbKt++rQLJlSXtXpS/CMLvIw/2CDntr+41 fZ6rj2DMn891DR8hFuJ5oenGxS4AnByCFEsHynkrm2Tvc2PgD1Qb5iBcGfz/U1t9NDA6 HIvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=NFTEtS7ylR+r71ytWpM5llFYDJmLmKZPStp+iTGLakU=; b=iKUoLVpl16PK4rz0/j0BR2EHckhd5O5fJAZepZzxD/r1iVtzSIWmhak48VESEh410A MMML5bgHKLwI0K+xI0/TZCLR2fkDJmSl2xvdwfJn0tutz1rFK8EIcdrattqyXCShLlmQ AUis142domudXcuQO+4DdkmuIx+nxs3MmF1JUWvELup6Vie8Gtu+lH0QrNre7IMMjwfi dm5fPR+yRo0EENXUuBIq5ajhhDxYvBi1HTWNm9sRSZaCIFHM7QYH3PqGWbv3y4s0msIh LtqBe0FuFv83My0PkiiY5jT8HPU4lM7rb+gAxqv7zpT3Zxvc6A242qzKh9d8PtYQglJ8 Iw1g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s5-20020a632c05000000b0042abd005029si9232612pgs.709.2022.08.24.18.42.47; Wed, 24 Aug 2022 18:42:58 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234152AbiHYBla (ORCPT + 99 others); Wed, 24 Aug 2022 21:41:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234589AbiHYBki (ORCPT ); Wed, 24 Aug 2022 21:40:38 -0400 Received: from mail.nfschina.com (unknown [IPv6:2400:dd01:100f:2:72e2:84ff:fe10:5f45]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EA6F19C2CD for ; Wed, 24 Aug 2022 18:38:09 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 611481E80CC4; Thu, 25 Aug 2022 09:34:04 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8hsjB63QpFXJ; Thu, 25 Aug 2022 09:34:01 +0800 (CST) Received: from localhost.localdomain.localdomain (unknown [219.141.250.2]) (Authenticated sender: lvqian@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 75BBF1E80C99; Thu, 25 Aug 2022 09:34:01 +0800 (CST) From: Lv qian To: jani.nikula@linux.intel.com, 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: [PATCH] drm/i915:Move the code position to reduce the number of judgments Date: Thu, 25 Aug 2022 09:37:52 +0800 Message-Id: <20220825013752.120988-1-lvqian@nfschina.com> X-Mailer: git-send-email 2.18.2 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 If the kmalloc allocation is successful, the if is judged twice, so I move the second judgment in to the first judgment. 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; -- 2.18.2