Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp144774rdh; Wed, 25 Oct 2023 20:02:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHUBhpUJkOgpM5Y9tab2Wg1U3flC4P8XxaClz6c8O3sc/GFYFc+ny5WWDsNoYaDJkRp2OuN X-Received: by 2002:a05:6808:1b0b:b0:3af:8ed3:d7a3 with SMTP id bx11-20020a0568081b0b00b003af8ed3d7a3mr18841392oib.54.1698289366091; Wed, 25 Oct 2023 20:02:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698289366; cv=none; d=google.com; s=arc-20160816; b=VFCW3hUlz7WhjtachNBZHHpj0PqBnMyXIX5x327MJelhPSmNjFYVSc3YSiLZuWF2v5 i0S2xZBJaOUfms+rxZ74aIk8BYxi/LaTgNAhyDXvcUcjW1cimt0JReIgzPlYu1gIckgU uQRHty0WJp/0KDmODZ4UhLrT6f854Qk6EO2+14HXcD2OEUaB1FoOeuvXUlDoRPKMykcU CcW/KXs6KQTjxoNKpUdh56V/eTwnmKwVgVE/GB3DBWN6/L/1/jExlGUpFwWYcPel0sAk Z0etZQCMzVwcFqR4OYLIhKPrs2lqvpeUqa0PWGHsfu5Qojp6wUTqqVVU8LRz8RX9A7eQ Wd2w== 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=qUJDiiJrDkoLHmh5dx9A91qbxRvC53OtInWuFnIX+88=; fh=iqBncDSqJNJjf6yrVTiC31xUXowzCoNhZDjpgC9Cf6o=; b=QX9DktDTWvBXFK5h0ryXIYhMnePS4xLtPBdvZqaq/c5clLlnh5qCAtB9hiKCMTgYnT IroL6R7ZZfMJmMcki7k4r/p1/tHlBGj5Bc1ftehc+z5MB6C3vcOs2K4pr0QmTjkX8Ii3 UmzDBHOFCObNMjp31dA+zYVovU7oMJh/Vj0XK9avuREOInsP/VljwMQ9lktXJ8xZsgvd T70iJidFSwNirFUa1H3QW7VHWj2dsuYdOsKv9Vw7zjHwxgGQjOlLl7F/hPiWXxZJGG7R V4cYl73AqUvrrcXrnHBXQLF6m695BqSxtQhpCJwF0LvupClIO8HIOrn1uX1nVExeGxCi 2GDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id q6-20020a056902150600b00d7b9fad2573si17640918ybu.213.2023.10.25.20.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 20:02:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 4E9EC8028527; Wed, 25 Oct 2023 20:02:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231190AbjJZDC2 (ORCPT + 99 others); Wed, 25 Oct 2023 23:02:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229554AbjJZDC0 (ORCPT ); Wed, 25 Oct 2023 23:02:26 -0400 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96FCF184 for ; Wed, 25 Oct 2023 20:02:22 -0700 (PDT) X-UUID: 481f77edae6f497cb21b70ea84cbe3e5-20231026 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.32,REQID:6b262220-f460-431a-acea-bc1b81d06392,IP:5,U RL:-32768,TC:0,Content:0,EDM:-30,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ha m,ACTION:release,TS:-40 X-CID-INFO: VERSION:1.1.32,REQID:6b262220-f460-431a-acea-bc1b81d06392,IP:5,URL :-32768,TC:0,Content:0,EDM:-30,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham, ACTION:release,TS:-40 X-CID-META: VersionHash:5f78ec9,CLOUDID:9bd954d7-04a0-4e50-8742-3543eab8cb8e,B ulkID:231026110216IKV1SZ4E,BulkQuantity:0,Recheck:0,SF:66|24|17|19|44,TC:n il,Content:0,EDM:2,IP:-2,URL:nil,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OS I:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: 481f77edae6f497cb21b70ea84cbe3e5-20231026 X-User: oushixiong@kylinos.cn Received: from localhost.localdomain [(116.128.244.169)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 1144456334; Thu, 26 Oct 2023 11:02:15 +0800 From: oushixiong To: Maarten Lankhorst Cc: Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Shixiong Ou Subject: [PATCH] drm/atomic-helper: Call stall_checks() before allocate drm_crtc_commit Date: Thu, 26 Oct 2023 11:02:13 +0800 Message-Id: <20231026030213.115505-1-oushixiong@kylinos.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 25 Oct 2023 20:02:42 -0700 (PDT) From: Shixiong Ou It is wrong to call stall_checks() after allocating memory for struct drm_crtc_commit as it will cause memory leaks if too many nonblock commit works return -EBUSY. So it needs to call stall_checks() before allocate drm_crtc_commit. Signed-off-by: Shixiong Ou --- drivers/gpu/drm/drm_atomic_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 2444fc33dd7c..94ea878b240d 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -2283,6 +2283,10 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state, funcs = state->dev->mode_config.helper_private; for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) { + ret = stall_checks(crtc, nonblock); + if (ret) + return ret; + commit = kzalloc(sizeof(*commit), GFP_KERNEL); if (!commit) return -ENOMEM; @@ -2291,10 +2295,6 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state, new_crtc_state->commit = commit; - ret = stall_checks(crtc, nonblock); - if (ret) - return ret; - /* * Drivers only send out events when at least either current or * new CRTC state is active. Complete right away if everything -- 2.25.1