Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp1666918rwl; Thu, 5 Jan 2023 17:47:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXubNeruFMMLcl+T0dGLlp/Hs16ZK86d1EIrl7Y6wIzWM1oqzM9FkpCrn3CxEG2G78M3o0su X-Received: by 2002:aa7:dcc9:0:b0:472:1436:73ab with SMTP id w9-20020aa7dcc9000000b00472143673abmr43408710edu.28.1672969642060; Thu, 05 Jan 2023 17:47:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672969642; cv=none; d=google.com; s=arc-20160816; b=up5SfQv6IjQBUFRT1Fx+SBNlCMDeJX7FIAY8/Uza89s1k4RH19ZLMJoQ/jFMw1KNz9 dTzrUQ/wsVvynKQ1vo+nkVoPa6yD3KY5pF9xm1fb8g8QvN7bY9sBez3IJj3euC+u2sEy EEnSGwvxuiPjTFfwAjHrpV5/BsRTZzlHwS/CS2IkFWH4muEfsnmQwsoOlDBIA13TZJgd kktJ2Lq7o1wR8GToSAFoCtDHYcF4IcxhGxPP5OADfJd0w/2aAi+0586qfxcYSuNLHRJ2 6yEFQdk9jBEiK7aZIwtqlUqtUJ8RXlQv0u8mNL8JA+1fi9yB0hSMs10VqopkFvWI8NOr Ejmw== 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=ngpMCU/yjb2jPrhSxrf0/j8YW0k621Tg5gwARjLlrvU=; b=ZkGkmIpmRkj92po+D4jGgXXDlqRNryX89o1+3NEX6bHukx2WfFCpAmUxaYhRSWss9T tsEgiJvID9xNWHCN/1XQV5kK+PngW0BfMRiwYNdmiawanXwQb+ufL5zdSCSuNL1PGaXm 3zxgCAy6Q5qW8fnmemd0UYxS0ijgp63aD44WZ5EDK6/m3ABNNqHcyXvrZU5HGNTgH5nc AGkpn+7OZat4QdE8tLSRmswhftS/UK6SFJR2IcOYFCO78Afca2zlxTnbld7wWWeALAI5 +lpBcNandGXoRXI+VfrZNbqXiXBLYnOUmoox53lNTCy5wOJs06E5F42fTSK4VFfjJ/Iy sZnA== 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 z5-20020aa7cf85000000b0048e913098c1si10566643edx.398.2023.01.05.17.47.09; Thu, 05 Jan 2023 17:47:22 -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 S230100AbjAFBii (ORCPT + 55 others); Thu, 5 Jan 2023 20:38:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229981AbjAFBig (ORCPT ); Thu, 5 Jan 2023 20:38:36 -0500 Received: from cstnet.cn (smtp25.cstnet.cn [159.226.251.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 099841B1F4; Thu, 5 Jan 2023 17:38:33 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.125]) by APP-05 (Coremail) with SMTP id zQCowADn7++Re7djDsVbCw--.11363S2; Fri, 06 Jan 2023 09:38:25 +0800 (CST) From: Jiasheng Jiang To: robdclark@gmail.com, quic_abhinavk@quicinc.com, dmitry.baryshkov@linaro.org, sean@poorly.run, airlied@gmail.com, sumit.semwal@linaro.org, christian.koenig@amd.com Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, Jiasheng Jiang Subject: [PATCH] drm/msm: Add missing check and destroy for alloc_ordered_workqueue Date: Fri, 6 Jan 2023 09:38:24 +0800 Message-Id: <20230106013824.27208-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: zQCowADn7++Re7djDsVbCw--.11363S2 X-Coremail-Antispam: 1UD129KBjvJXoW7urWkCF4DJFyxtFykJw43KFg_yoW8Xr4kpa 13AayrtryFya1agwnFyr1kua45C3W8K3WfC3yI9wnIgwn0yr4DAa48tFyjkry3GFZ7XF12 yFZ2ya4DZF1jkrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvm14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r1Y6r17McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxa n2IY04v7MxkIecxEwVAFwVWkMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r 4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF 67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2I x0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2 z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnU UI43ZEXa7VUbNzVUUUUUU== 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 Add check for the return value of alloc_ordered_workqueue as it may return NULL pointer. Moreover, use the destroy_workqueue in the later fails in order to avoid memory leak. Fixes: c8afe684c95c ("drm/msm: basic KMS driver for snapdragon") Signed-off-by: Jiasheng Jiang --- drivers/gpu/drm/msm/msm_drv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 8b0b0ac74a6f..b82d938226ad 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -418,6 +418,8 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) priv->dev = ddev; priv->wq = alloc_ordered_workqueue("msm", 0); + if (!priv->wq) + return -ENOMEM; INIT_LIST_HEAD(&priv->objects); mutex_init(&priv->obj_lock); @@ -440,12 +442,12 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) ret = msm_init_vram(ddev); if (ret) - return ret; + goto err_destroy_workqueue; /* Bind all our sub-components: */ ret = component_bind_all(dev, ddev); if (ret) - return ret; + goto err_destroy_workqueue; dma_set_max_seg_size(dev, UINT_MAX); @@ -540,6 +542,8 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) err_msm_uninit: msm_drm_uninit(dev); +err_destroy_workqueue: + destroy_workqueue(priv->wq); return ret; } -- 2.25.1