Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp8037725rwl; Tue, 10 Jan 2023 08:18:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXtvzXvctOsX+/7mbo67yQfUd9e3Ppqa9fb/hexz0jc6dbEa4k4uebcbDo1C8htQd8s/tmVo X-Received: by 2002:a05:6a20:3c8f:b0:a3:bdd3:8cb0 with SMTP id b15-20020a056a203c8f00b000a3bdd38cb0mr99287606pzj.56.1673367525435; Tue, 10 Jan 2023 08:18:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673367525; cv=none; d=google.com; s=arc-20160816; b=x/4NAQVmUk/kMFjumBv+xyvyHjmV8ydBtBCI38tyPM7h6tVfTUOT55m9x794Op9nAJ +2X4T2jp1raPooVGXArALemV7vx2/GcmU9m2rI4kn81uPPVc73b+jEauXM4Wem+cWH1w kkJ+/PtTbkb6mpwGBkyoXYjm/4Yzfw47kiUOon6r1RfFBPUCEoALAZxTpS453Djy0iGG 501A9XZRCGq3CW3it43w6xkHozp5w85sOlB8f7N2qyzQKVB3q4W3pQ47nqE9Bv5cUNpz qqPtgIM5eKRj9KRrWi2YgjpZDs7+Is8bGG+gDOU6cjKsxY/Wry+MpFt4wyItwZ8fno4i Nsvw== 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=ewFcuFiDrsHp/J0ly608gyW9TNAXzIbAPAP7JNAsZOI=; b=d1RiJ79iYm8x+nPeRQuCCTEqjZaoDbdBJxUgxuu9f9sSglg77JEXu1o+ZaDNqA1pUk 3uEJUqwJYlYjuT9OHLUhPEOmPb8Ix5UAswJVWmY9VesqhKIYivRl3t3Nofj0jBDWcDnc h5RGq/M3HnRFPqTDmLXECaKSRiY3gcwOu0D9Vmu0/Z6ZJDN6+oGbVW0hGRac6DD+x3Lo EVb3GEBVmx+8hj4anK15vrV++wGYgKe5pEfdRB9asisZ2rRxjYLsKBa6c4vHA54qywVv R3xZ1JpesklRSkRtIHlV09eBLbnYV/Qje+ufRh3p0WyArErNHz/E1gyXETcY27JqRtAz +wCQ== 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 d20-20020a63ed14000000b00477f88e3c28si11940155pgi.267.2023.01.10.08.18.36; Tue, 10 Jan 2023 08:18:45 -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 S234767AbjAJPiQ (ORCPT + 53 others); Tue, 10 Jan 2023 10:38:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234087AbjAJPiN (ORCPT ); Tue, 10 Jan 2023 10:38:13 -0500 Received: from cstnet.cn (smtp25.cstnet.cn [159.226.251.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C34F01F5 for ; Tue, 10 Jan 2023 07:38:11 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.125]) by APP-05 (Coremail) with SMTP id zQCowADH6M1chr1juvoNDA--.26915S2; Tue, 10 Jan 2023 23:38:04 +0800 (CST) From: Jiasheng Jiang To: daniel@ffwll.ch Cc: jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, tvrtko.ursulin@linux.intel.com, airlied@gmail.com, ville.syrjala@linux.intel.com, manasi.d.navare@intel.com, stanislav.lisovskiy@intel.com, lucas.demarchi@intel.com, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: Re: [PATCH] drm/i915: Add missing check and destroy for alloc_workqueue Date: Tue, 10 Jan 2023 23:38:03 +0800 Message-Id: <20230110153803.5755-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: zQCowADH6M1chr1juvoNDA--.26915S2 X-Coremail-Antispam: 1UD129KBjvJXoW7tw1xWF43WF1fArWfKr1xKrg_yoW8Ww1fpF 43XFyjkrZ5GayUGa9Fyw48tFyfA3yUGa4rGrykWryqv3W5Arn3C3sYkFy5uFyxAFZxXF1j yFZ0939ruF1qy3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvG14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r1j6r1xM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628v n2kIc2xKxwCY02Avz4vE14v_XrWl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjfU8eOJUUUUU X-Originating-IP: [124.16.138.125] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS 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 On Sat, Jan 07, 2023 at 02:29:22AM +0800, Daniel Vetter wrote: >On Fri, Jan 06, 2023 at 05:09:34PM +0800, Jiasheng Jiang wrote: >> Add checks for the return value of alloc_workqueue and >> alloc_ordered_workqueue as they may return NULL pointer and cause NULL >> pointer dereference. >> Moreover, destroy them when fails later in order to avoid memory leak. >> Because in `drivers/gpu/drm/i915/i915_driver.c`, if >> intel_modeset_init_noirq fails, its workqueues will not be destroyed. >> >> Fixes: c26a058680dc ("drm/i915: Use a high priority wq for nonblocking plane updates") >> Fixes: 757fffcfdffb ("drm/i915: Put all non-blocking modesets onto an ordered wq") >> Signed-off-by: Jiasheng Jiang > > So you have an entire pile of these, and I think that's a really good > excuse to > - create a drmm_alloc_workqueue helper for these (and > drmm_alloc_ordered_workqueue) using the drmm_add_action_or_reset() > function for automatic drm_device cleanup > - use that instead in all drivers, which means you do not have to make any > error handling mor complex > > Up for that? In that case please also convert any existing alloc*workqueue > callsites in drm, and make this all a patch series (since then there would > be dependencies). Fine, I have submitted two patches. The first one create the drmm_alloc_workqueue and drmm_alloc_ordered_workqueue helpers. And the second one replace the alloc*workqueue with DRM helpers in `drivers/gpu/drm/i915/display/intel_display.c`. If there is no problem in these two, I will submitted the other patches that replace the alloc*workqueue in other DRM files. Thanks, Jiang