Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35167437rwd; Mon, 10 Jul 2023 03:42:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlF9xMlB2J7QWaHXjshol/My6tZe/yub9YlBPkXs9HiIJV5xtHm80fnX2/S/x76cLBX0GECy X-Received: by 2002:a19:3817:0:b0:4f8:6ac1:15a9 with SMTP id f23-20020a193817000000b004f86ac115a9mr8401409lfa.31.1688985738955; Mon, 10 Jul 2023 03:42:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688985738; cv=none; d=google.com; s=arc-20160816; b=YTz3fxFvRi9AnTqF2SbK+GNZcdg2N1dxItlKCwGXF+VZwXjSDtDQYlls8o7Me8oN1T HTNejC2kUIwnDT0CfeNONEzcu668+yIjtMEU/S8nHXdBiEU5JfinYrwrzlAhWnu2dEGm csTBllS/HQyyBqE23wA9qbQUIsJuFyvIPWoiqWNBDQxggba6gEWFGkoUikLeGPvAAZJh E+axRVVX7ralEXMX4q62FHtKEK9y/k8sB39VqroMgZv5niSbTDgG+TkFlb2ptZ5JAZdQ Veui/NDAQzn/s0C+3M36hHscuT6+8kynb8+CxmXYt7uuDogTuUXsHG+D5ZCbcE0yGKwc 5TvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=lYh6AdmA1wQqi7gqa+rN/yHtFO+/US+pIcNcolYMpMk=; fh=/imtygYF83geoTkkjOAZ3/yTMXt4vTj/TooI+mNsldo=; b=ODjWXrAUoP+prv0hxl8rp+fZWsymRABgF94csKf+iKYd3WthhA4685/CTUgN/8/G9v xNSJCu460Uy+ZxivDx6ov6hKEcte28mhAi6OJstu+cjvzA34iJ9modb8eJsYMBLICU7C dnKPEduSrVEAyR967gFBpVHoSOQoSO+kvTqGIU1OLHAQnTIN74fHN+A4GjIsB82LbNbG 1m8UcIKbQiHsBCrqtd2IqanrHdM4B7ZiOE3QDBPVdHJMCtweKxgWWobQaAoOI924Uaxs OktwzlrkMX3nstZkuEz1SllVnDvMA+/FLv5AN0E441YvRAq/mrFlLQnvwKd2KetyeUxi LMfw== 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 lu13-20020a170906facd00b0098d0a88d4fasi9408140ejb.808.2023.07.10.03.41.54; Mon, 10 Jul 2023 03:42:18 -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 S231982AbjGJKYU (ORCPT + 99 others); Mon, 10 Jul 2023 06:24:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230345AbjGJKYS (ORCPT ); Mon, 10 Jul 2023 06:24:18 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2EE5F95 for ; Mon, 10 Jul 2023 03:24:16 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.43]) by gateway (Coremail) with SMTP id _____8AxDOtP3KtkHxkDAA--.3709S3; Mon, 10 Jul 2023 18:24:15 +0800 (CST) Received: from openarena.loongson.cn (unknown [10.20.42.43]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cx7yNP3Ktk6SYnAA--.5526S2; Mon, 10 Jul 2023 18:24:15 +0800 (CST) From: Sui Jingfeng To: Sui Jingfeng , David Airlie , Daniel Vetter , Thomas Zimmermann , Li Yi Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn, Dan Carpenter Subject: [PATCH] drm/loongson: Remove a useless check in cursor_plane_atomic_async_check() Date: Mon, 10 Jul 2023 18:24:11 +0800 Message-Id: <20230710102411.257970-1-suijingfeng@loongson.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8Cx7yNP3Ktk6SYnAA--.5526S2 X-CM-SenderInfo: xvxlyxpqjiv03j6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBj93XoW7KrWDXrykAr18GrW3CF48AFc_yoW8tF1rp3 9FkryFkrW5Jrn7tr9rJwn8KrZxuayxGryIgFWUGw1SqFW0kry3Jr1kurZrurW7ZrW7G347 trn7CFs0ga1UK3XCm3ZEXasCq-sJn29KB7ZKAUJUUUU7529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUU9Fb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2kKe7AKxVWUXVWUAwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07 AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWU AVWUtwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7V AKI48JMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMxCIbckI1I0E14v2 6r1Y6r17MI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17 CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF 0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIx AIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2 KfnxnUUI43ZEXa7IU8uuWJUUUUU== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Because smatch warnings: drivers/gpu/drm/loongson/lsdc_plane.c:199 lsdc_cursor_plane_atomic_async_check() warn: variable dereferenced before check 'state' (see line 180) vim +/state +199 drivers/gpu/drm/loongson/lsdc_plane.c 174 static int lsdc_cursor_plane_atomic_async_check(struct drm_plane *plane, 175 struct drm_atomic_state *state) 176 { 177 struct drm_plane_state *new_state; 178 struct drm_crtc_state *crtc_state; 179 180 new_state = drm_atomic_get_new_plane_state(state, plane); ^^^^^ state is dereferenced inside this function 181 182 if (!plane->state || !plane->state->fb) { 183 drm_dbg(plane->dev, "%s: state is NULL\n", plane->name); 184 return -EINVAL; 185 } 186 187 if (new_state->crtc_w != new_state->crtc_h) { 188 drm_dbg(plane->dev, "unsupported cursor size: %ux%u\n", 189 new_state->crtc_w, new_state->crtc_h); 190 return -EINVAL; 191 } 192 193 if (new_state->crtc_w != 64 && new_state->crtc_w != 32) { 194 drm_dbg(plane->dev, "unsupported cursor size: %ux%u\n", 195 new_state->crtc_w, new_state->crtc_h); 196 return -EINVAL; 197 } 198 199 if (state) { ^^^^^ Checked too late! Reported-by: Dan Carpenter Closes: https://lore.kernel.org/r/202307100423.rV7D05Uq-lkp@intel.com/ Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/loongson/lsdc_plane.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/gpu/drm/loongson/lsdc_plane.c b/drivers/gpu/drm/loongson/lsdc_plane.c index 2ab3db982aa3..0d5094633222 100644 --- a/drivers/gpu/drm/loongson/lsdc_plane.c +++ b/drivers/gpu/drm/loongson/lsdc_plane.c @@ -196,13 +196,7 @@ static int lsdc_cursor_plane_atomic_async_check(struct drm_plane *plane, return -EINVAL; } - if (state) { - crtc_state = drm_atomic_get_existing_crtc_state(state, new_state->crtc); - } else { - crtc_state = plane->crtc->state; - drm_dbg(plane->dev, "%s: atomic state is NULL\n", plane->name); - } - + crtc_state = drm_atomic_get_existing_crtc_state(state, new_state->crtc); if (!crtc_state->active) return -EINVAL; -- 2.34.1