From patchwork Fri Jan 6 02:56:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiasheng Jiang X-Patchwork-Id: 13090813 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E84A6C3DA7A for ; Fri, 6 Jan 2023 02:56:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229532AbjAFC42 (ORCPT ); Thu, 5 Jan 2023 21:56:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229994AbjAFC4Z (ORCPT ); Thu, 5 Jan 2023 21:56:25 -0500 Received: from cstnet.cn (smtp23.cstnet.cn [159.226.251.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1F16D671AD; Thu, 5 Jan 2023 18:56:20 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.125]) by APP-03 (Coremail) with SMTP id rQCowAAHDZXKjbdjuQe+Cg--.60117S2; Fri, 06 Jan 2023 10:56:10 +0800 (CST) From: Jiasheng Jiang To: robdclark@gmail.com, quic_abhinavk@quicinc.com, dmitry.baryshkov@linaro.org, sean@poorly.run, airlied@gmail.com, daniel@ffwll.ch, marijn.suijten@somainline.org, vkoul@kernel.org, dianders@chromium.org, marex@denx.de, vladimir.lypak@gmail.com Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] drm/msm/dsi: Add missing check for alloc_ordered_workqueue Date: Fri, 6 Jan 2023 10:56:09 +0800 Message-Id: <20230106025609.29499-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 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xBIdaVFxhVjvj DU0xZFpf9x0JUyxRDUUUUU= X-Originating-IP: [124.16.138.125] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add check for the return value of alloc_ordered_workqueue as it may return NULL pointer and cause NULL pointer dereference. Moreover, change the "return ret" into "goto fail" in order to be consistent with the others. Fixes: a689554ba6ed ("drm/msm: Initial add DSI connector support") Fixes: 32d3e0feccfe ("drm/msm: dsi: Use OPP API to set clk/perf state") Signed-off-by: Jiasheng Jiang --- drivers/gpu/drm/msm/dsi/dsi_host.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c index 89aadd3b3202..12239f628d5a 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_host.c +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c @@ -1944,19 +1944,19 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi) ret = devm_pm_opp_set_clkname(&pdev->dev, "byte"); if (ret) - return ret; + goto fail; /* OPP table is optional */ ret = devm_pm_opp_of_add_table(&pdev->dev); if (ret && ret != -ENODEV) { dev_err(&pdev->dev, "invalid OPP table in device tree\n"); - return ret; + goto fail; } msm_host->irq = irq_of_parse_and_map(pdev->dev.of_node, 0); if (msm_host->irq < 0) { ret = msm_host->irq; dev_err(&pdev->dev, "failed to get irq: %d\n", ret); - return ret; + goto fail; } /* do not autoenable, will be enabled later */ @@ -1966,7 +1966,7 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi) if (ret < 0) { dev_err(&pdev->dev, "failed to request IRQ%u: %d\n", msm_host->irq, ret); - return ret; + goto fail; } init_completion(&msm_host->dma_comp); @@ -1977,6 +1977,11 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi) /* setup workqueue */ msm_host->workqueue = alloc_ordered_workqueue("dsi_drm_work", 0); + if (!msm_host->workqueue) { + ret = -ENOMEM; + goto fail; + } + INIT_WORK(&msm_host->err_work, dsi_err_worker); msm_dsi->id = msm_host->id;