From patchwork Tue Nov 8 10:55:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KaiLong Wang X-Patchwork-Id: 16982 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2630152wru; Tue, 8 Nov 2022 03:01:58 -0800 (PST) X-Google-Smtp-Source: AMsMyM7vN7Uda9mzBXWiJX+DUtcrxGjfhrNLDjD65FAZ617+9Y3rOqfYh8m+8Q8mHf2QqEEQ+V4o X-Received: by 2002:a17:906:db0a:b0:781:f24:a782 with SMTP id xj10-20020a170906db0a00b007810f24a782mr52787421ejb.399.1667905318556; Tue, 08 Nov 2022 03:01:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667905318; cv=none; d=google.com; s=arc-20160816; b=jcmzqr5A86WOd+3pU5hJ3SIKxfIVT8+4YUEGLQ7a5RS7Jcp8wsXgj+pygirAOK2k5v lW3r4aPxboOS9p8tudVzZsLMmFk69VafldcWk2CvlA0qB/Hfjym9NxOfBO0JumS4NjD8 r0RY9aMtdB58DBMa9QCmbJJUi+hI3kXJLUuEyQY0zJVQjfejqd5lr+q20ywCra4cnFyQ k5jogKc3EFb6FVgUA4uf0HOEG2dPzrQyrtPcC3oQKKJpbbqfx03217skue0j7laVtzqX D6wnYB8Rkdh5D2+O3aN/OUsYzGPD3qll01sEWmkB8+hfUAEC2NlJ/D+MNbfa/+PY8ebu Z5BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:mime-version :content-transfer-encoding:subject:cc:to:from:date; bh=j1v9LLMudnVplkvSffrfFyeVug6QZ0hJMQu3JlDl3Zg=; b=CsYkQ/wBrT8OBDr7Kep2qgoOetDTTVjD2pfl6MwhBcQ3tJSo7obDl3XwvC08zimTj1 iEyStmRm3PirRs4KBN9gsdzZgdoTY4yRGJ1KZbxplcQSueljX1atmY0dgNS4g9M9+3hK bXZImaPTYtqpGTxLIQ0JspMUyt4+B9/x6Q/gNbkHlhvSGdcR1JXDYa9wYf/zrqm47xow mQQ2BMGPwxMHq5oIf2ZgkRQNVAnXwtXl3b3Pre8zpiykH4jQ+OqYBeIvPZPsXn7dwqJH d7I3D241iKPRfn847yupLnfKo5mWQw2uC/lyOh3rPS3UFJyQORGlznQbczF7gw/q1NKZ 4W/A== 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 ci4-20020a170906c34400b00781599eb7dbsi9123838ejb.573.2022.11.08.03.01.34; Tue, 08 Nov 2022 03:01:58 -0800 (PST) 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 S233784AbiKHLAE (ORCPT + 99 others); Tue, 8 Nov 2022 06:00:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233479AbiKHLAD (ORCPT ); Tue, 8 Nov 2022 06:00:03 -0500 Received: from jari.cn (unknown [218.92.28.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7CA14450B3 for ; Tue, 8 Nov 2022 02:59:54 -0800 (PST) Received: by ajax-webmail-localhost.localdomain (Coremail) ; Tue, 8 Nov 2022 18:55:03 +0800 (GMT+08:00) X-Originating-IP: [182.148.13.29] Date: Tue, 8 Nov 2022 18:55:03 +0800 (GMT+08:00) X-CM-HeaderCharset: UTF-8 From: wangkailong@jari.cn To: Wentland , Li , Siqueira , Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , Airlie , Vetter Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/amd/display: fix array-bounds error in dc_stream_remove_writeback() X-Priority: 3 X-Mailer: Coremail Webmail Server Version XT6.0.1 build 20210329(c53f3fee) Copyright (c) 2002-2022 www.mailtech.cn mispb-4e503810-ca60-4ec8-a188-7102c18937cf-zhkzyfz.cn MIME-Version: 1.0 Message-ID: <7bafafdf.f5.18456e11abd.Coremail.wangkailong@jari.cn> X-Coremail-Locale: zh_CN X-CM-TRANSID: AQAAfwCXn+CHNWpjAcsBAA--.39W X-CM-SenderInfo: 5zdqwypdlo00nj6mt2flof0/1tbiAQAEB2FEYx0DdQABsu X-Coremail-Antispam: 1Ur529EdanIXcx71UUUUU7IcSsGvfJ3iIAIbVAYjsxI4VWxJw CS07vEb4IE77IF4wCS07vE1I0E4x80FVAKz4kxMIAIbVAFxVCaYxvI4VCIwcAKzIAtYxBI daVFxhVjvjDU= X-Spam-Status: No, score=2.2 required=5.0 tests=BAYES_00,RCVD_IN_PBL,RDNS_NONE, T_SPF_HELO_PERMERROR,T_SPF_PERMERROR,XPRIO autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748925487167721833?= X-GMAIL-MSGID: =?utf-8?q?1748925487167721833?= replace the subsequent check for 'i != j' with Delete header file "timing_generator.h" Signed-off-by: KaiLong Wang --- drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c index 38d71b5c1f2d..66661a20117b 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c @@ -29,7 +29,6 @@ #include "core_types.h" #include "resource.h" #include "ipp.h" -#include "timing_generator.h" #include "dc_dmub_srv.h" #define DC_LOGGER dc->ctx->logger @@ -152,9 +151,8 @@ static void dc_stream_free(struct kref *kref) void dc_stream_release(struct dc_stream_state *stream) { - if (stream != NULL) { + if (stream != NULL) kref_put(&stream->refcount, dc_stream_free); - } } struct dc_stream_state *dc_create_stream_for_sink( @@ -316,11 +314,11 @@ bool dc_stream_set_cursor_attributes( struct dc *dc; bool reset_idle_optimizations = false; - if (NULL == stream) { + if (stream == NULL) { dm_error("DC: dc_stream is NULL!\n"); return false; } - if (NULL == attributes) { + if (attributes == NULL) { dm_error("DC: attributes is NULL!\n"); return false; } @@ -399,12 +397,12 @@ bool dc_stream_set_cursor_position( struct dc *dc = stream->ctx->dc; bool reset_idle_optimizations = false; - if (NULL == stream) { + if (stream == NULL) { dm_error("DC: dc_stream is NULL!\n"); return false; } - if (NULL == position) { + if (position == NULL) { dm_error("DC: cursor position is NULL!\n"); return false; } @@ -468,9 +466,8 @@ bool dc_stream_add_writeback(struct dc *dc, } } - if (!isDrc) { + if (!isDrc) stream->writeback_info[stream->num_wb_info++] = *wb_info; - } if (dc->hwss.enable_writeback) { struct dc_stream_status *stream_status = dc_stream_get_status(stream); @@ -526,7 +523,7 @@ bool dc_stream_remove_writeback(struct dc *dc, /* remove writeback info for disabled writeback pipes from stream */ for (i = 0, j = 0; i < stream->num_wb_info; i++) { if (stream->writeback_info[i].wb_enabled) { - if (j < i) + if (i != j) /* trim the array */ stream->writeback_info[j] = stream->writeback_info[i]; j++;