From patchwork Mon Jul 10 10:24:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 117825 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp4924914vqx; Mon, 10 Jul 2023 03:32:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlEfkn+xPFH2fHIqoESJZtYmNYapsRCYdLnmNxbCNVjidaw+cV2QeCQugr7MBwk0lzL87M/0 X-Received: by 2002:a17:903:244d:b0:1b7:f24c:3b9a with SMTP id l13-20020a170903244d00b001b7f24c3b9amr16167834pls.47.1688985148228; Mon, 10 Jul 2023 03:32:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688985148; cv=none; d=google.com; s=arc-20160816; b=A9nbPeWGaUqOujClBYcv6mufEPT4CCE3bNJ1jUrY5r7AHstge25B1qHXg6Mb6DiNyG lkjWJLd+l4i+UwjtHq7iOvNMyjAf/PdjOn1xuUNlnJt6XbOutf7oyWSdQnXJ4F8tOYZf dOChk7JCipF/zVGkQ46Cap6PdkmS5F+gFUbzthU+8XcAq/sTweaM1pBTxF/7WHqsxIZD nS6rdtBHfadYFpUASTn82VQ4d5qrv8MzEBQaTQckoj6QbZE3nDG9vDDZOT+XeFhNFzmZ orHnmoinK/JcYdE3hdDhgPt362ZXPf86a54xH0QY3UYCK9di9pX7i2lYF+ZvbS82YDcu Bvvw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w1-20020a170902e88100b001b6680bc871si9264079plg.445.2023.07.10.03.32.16; Mon, 10 Jul 2023 03:32: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; 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 S232011AbjGJKYU (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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771029290503077233 X-GMAIL-MSGID: 1771029290503077233 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 Acked-by: Thomas Zimmermann --- 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;