[PATCH] drm/vc4: Fix refcount leak in vc4_hvs_bind
rpi_firmware_get() takes refcount, we should release it with rpi_firmware_put(), add missing rpi_firmware_put() in the error path. Fixes: 2a001ca00ad5 ("drm/vc4: hdmi: Rework hdmi_enable_4kp60 detection code") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/vc4/vc4_hvs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/vc4/vc4_hvs.c b/drivers/gpu/drm/vc4/vc4_hvs.c index c4453a5ae163..816844ea60b1 100644 --- a/drivers/gpu/drm/vc4/vc4_hvs.c +++ b/drivers/gpu/drm/vc4/vc4_hvs.c @@ -809,6 +809,7 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data) hvs->core_clk = devm_clk_get(>dev, NULL); if (IS_ERR(hvs->core_clk)) { dev_err(>dev, "Couldn't get core clock\n"); + rpi_firmware_put(firmware); return PTR_ERR(hvs->core_clk); } -- 2.25.1
[PATCH] backlight: backlight: Fix doc for backlight_device_get_by_name
backlight_put() has been dropped, we should call put_device() to drop the reference taken by backlight_device_get_by_name(). Fixes: 0f6a3256fd81 ("backlight: backlight: Drop backlight_put()") Signed-off-by: Miaoqian Lin --- drivers/video/backlight/backlight.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index b788ff3d0f45..6eea72aa8dbf 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c @@ -501,7 +501,7 @@ EXPORT_SYMBOL(backlight_device_get_by_type); * * This function looks up a backlight device by its name. It obtains a reference * on the backlight device and it is the caller's responsibility to drop the - * reference by calling backlight_put(). + * reference by calling put_device(). * * Returns: * A pointer to the backlight device if found, otherwise NULL. -- 2.25.1
[PATCH] drm/i915: Fix documentation for intel_uncore_forcewake_put__locked
intel_uncore_forcewake_put__locked() is used to release a reference. Fixes: a6111f7b6604 ("drm/i915: Reduce locking in execlist command submission") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/i915/intel_uncore.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c index 5cd423c7b646..acb40543eb32 100644 --- a/drivers/gpu/drm/i915/intel_uncore.c +++ b/drivers/gpu/drm/i915/intel_uncore.c @@ -819,9 +819,9 @@ void intel_uncore_forcewake_flush(struct intel_uncore *uncore, } /** - * intel_uncore_forcewake_put__locked - grab forcewake domain references + * intel_uncore_forcewake_put__locked - release forcewake domain references * @uncore: the intel_uncore structure - * @fw_domains: forcewake domains to get reference on + * @fw_domains: forcewake domains to put references * * See intel_uncore_forcewake_put(). This variant places the onus * on the caller to explicitly handle the dev_priv->uncore.lock spinlock. -- 2.25.1
[PATCH v2] drm/msm/dpu: Fix memory leak in msm_mdss_parse_data_bus_icc_path
of_icc_get() alloc resources for path1, we should release it when not need anymore. Early return when IS_ERR_OR_NULL(path0) may leak path1. Defer getting path1 to fix this. Fixes: b9364eed9232 ("drm/msm/dpu: Move min BW request and full BW disable back to mdss") Signed-off-by: Miaoqian Lin --- changes in v2: - move getting path1 after error check for path0. --- drivers/gpu/drm/msm/msm_mdss.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_mdss.c b/drivers/gpu/drm/msm/msm_mdss.c index e13c5c12b775..3b8d6991b04e 100644 --- a/drivers/gpu/drm/msm/msm_mdss.c +++ b/drivers/gpu/drm/msm/msm_mdss.c @@ -46,15 +46,17 @@ struct msm_mdss { static int msm_mdss_parse_data_bus_icc_path(struct device *dev, struct msm_mdss *msm_mdss) { - struct icc_path *path0 = of_icc_get(dev, "mdp0-mem"); - struct icc_path *path1 = of_icc_get(dev, "mdp1-mem"); + struct icc_path *path0; + struct icc_path *path1; + path0 = of_icc_get(dev, "mdp0-mem"); if (IS_ERR_OR_NULL(path0)) return PTR_ERR_OR_ZERO(path0); msm_mdss->path[0] = path0; msm_mdss->num_paths = 1; + path1 = of_icc_get(dev, "mdp1-mem"); if (!IS_ERR_OR_NULL(path1)) { msm_mdss->path[1] = path1; msm_mdss->num_paths++; -- 2.25.1
[PATCH] drm/msm/dpu: Fix memory leak in msm_mdss_parse_data_bus_icc_path
of_icc_get() alloc resources for path1, we should release it when not need anymore. Early return when IS_ERR_OR_NULL(path0) may leak path1. Add icc_put(path1) in the error path to fix this. Fixes: b9364eed9232 ("drm/msm/dpu: Move min BW request and full BW disable back to mdss") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/msm/msm_mdss.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/msm_mdss.c b/drivers/gpu/drm/msm/msm_mdss.c index e13c5c12b775..a38fa9a9a3d6 100644 --- a/drivers/gpu/drm/msm/msm_mdss.c +++ b/drivers/gpu/drm/msm/msm_mdss.c @@ -49,8 +49,10 @@ static int msm_mdss_parse_data_bus_icc_path(struct device *dev, struct icc_path *path0 = of_icc_get(dev, "mdp0-mem"); struct icc_path *path1 = of_icc_get(dev, "mdp1-mem"); - if (IS_ERR_OR_NULL(path0)) + if (IS_ERR_OR_NULL(path0)) { + icc_put(path1); return PTR_ERR_OR_ZERO(path0); + } msm_mdss->path[0] = path0; msm_mdss->num_paths = 1; -- 2.25.1
Re: [PATCH] drm/msm/mdp4: Fix refcount leak in mdp4_modeset_init_intf
Hi, Abhinav On 2022/6/11 7:20, Abhinav Kumar wrote: > > > On 6/7/2022 4:08 AM, Miaoqian Lin wrote: >> of_graph_get_remote_node() returns remote device node pointer with >> refcount incremented, we should use of_node_put() on it >> when not need anymore. >> Add missing of_node_put() to avoid refcount leak. >> >> Fixes: 86418f90a4c1 ("drm: convert drivers to use of_graph_get_remote_node") >> Signed-off-by: Miaoqian Lin >> --- >> drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c | 2 ++ >> 1 file changed, 2 insertions(+) >> > > This patch itself looks fine and will cover the cases when there was an error > and we did not release the refcount. > > But, even in the normal cases I am not finding where we are releasing the > refcount for the panel_node. > > I dont see a of_node_put() on mdp4_lcdc_encoder->panel_node. > Thanks for your review. I don't see it either. It's a bit messy because the reference assigned to mdp4_lcdc_encoder->panel_node and mdp4_lvds_connector->panel_node both. > Am i missing something? > >> diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c >> b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c >> index fb48c8c19ec3..17cb1fc78379 100644 >> --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c >> +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c >> @@ -216,6 +216,7 @@ static int mdp4_modeset_init_intf(struct mdp4_kms >> *mdp4_kms, >> encoder = mdp4_lcdc_encoder_init(dev, panel_node); >> if (IS_ERR(encoder)) { >> DRM_DEV_ERROR(dev->dev, "failed to construct LCDC encoder\n"); >> + of_node_put(panel_node); >> return PTR_ERR(encoder); >> } >> @@ -225,6 +226,7 @@ static int mdp4_modeset_init_intf(struct mdp4_kms >> *mdp4_kms, >> connector = mdp4_lvds_connector_init(dev, panel_node, encoder); >> if (IS_ERR(connector)) { >> DRM_DEV_ERROR(dev->dev, "failed to initialize LVDS >> connector\n"); >> + of_node_put(panel_node); >> return PTR_ERR(connector); >> } >>
[PATCH] drm/msm/mdp4: Fix refcount leak in mdp4_modeset_init_intf
of_graph_get_remote_node() returns remote device node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Add missing of_node_put() to avoid refcount leak. Fixes: 86418f90a4c1 ("drm: convert drivers to use of_graph_get_remote_node") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c index fb48c8c19ec3..17cb1fc78379 100644 --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c @@ -216,6 +216,7 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms, encoder = mdp4_lcdc_encoder_init(dev, panel_node); if (IS_ERR(encoder)) { DRM_DEV_ERROR(dev->dev, "failed to construct LCDC encoder\n"); + of_node_put(panel_node); return PTR_ERR(encoder); } @@ -225,6 +226,7 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms, connector = mdp4_lvds_connector_init(dev, panel_node, encoder); if (IS_ERR(connector)) { DRM_DEV_ERROR(dev->dev, "failed to initialize LVDS connector\n"); + of_node_put(panel_node); return PTR_ERR(connector); } -- 2.25.1
[PATCH v2] drm/tegra: dc: rgb: Fix refcount leak in tegra_dc_rgb_probe
of_get_child_by_name() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. So add of_node_put() in error paths. Fixes: d8f4a9eda006 ("drm: Add NVIDIA Tegra20 support") Signed-off-by: Miaoqian Lin --- changes in v2: - update Fixes tag. v1 Link: https://lore.kernel.org/r/20220602155615.43277-1-linmq...@gmail.com --- drivers/gpu/drm/tegra/rgb.c | 31 +-- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c index ff8fce36d2aa..cef2b1b72385 100644 --- a/drivers/gpu/drm/tegra/rgb.c +++ b/drivers/gpu/drm/tegra/rgb.c @@ -196,12 +196,16 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc) int err; np = of_get_child_by_name(dc->dev->of_node, "rgb"); - if (!np || !of_device_is_available(np)) - return -ENODEV; + if (!np || !of_device_is_available(np)) { + err = -ENODEV; + goto err_put_node; + } rgb = devm_kzalloc(dc->dev, sizeof(*rgb), GFP_KERNEL); - if (!rgb) - return -ENOMEM; + if (!rgb) { + err = -ENOMEM; + goto err_put_node; + } rgb->output.dev = dc->dev; rgb->output.of_node = np; @@ -209,31 +213,34 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc) err = tegra_output_probe(>output); if (err < 0) - return err; + goto err_put_node; + rgb->clk = devm_clk_get(dc->dev, NULL); if (IS_ERR(rgb->clk)) { dev_err(dc->dev, "failed to get clock\n"); - return PTR_ERR(rgb->clk); + err = PTR_ERR(rgb->clk); + goto err_put_node; } rgb->clk_parent = devm_clk_get(dc->dev, "parent"); if (IS_ERR(rgb->clk_parent)) { dev_err(dc->dev, "failed to get parent clock\n"); - return PTR_ERR(rgb->clk_parent); + err = PTR_ERR(rgb->clk_parent); + goto err_put_node; } err = clk_set_parent(rgb->clk, rgb->clk_parent); if (err < 0) { dev_err(dc->dev, "failed to set parent clock: %d\n", err); - return err; + goto err_put_node; } rgb->pll_d_out0 = clk_get_sys(NULL, "pll_d_out0"); if (IS_ERR(rgb->pll_d_out0)) { err = PTR_ERR(rgb->pll_d_out0); dev_err(dc->dev, "failed to get pll_d_out0: %d\n", err); - return err; + goto err_put_node; } if (dc->soc->has_pll_d2_out0) { @@ -241,13 +248,17 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc) if (IS_ERR(rgb->pll_d2_out0)) { err = PTR_ERR(rgb->pll_d2_out0); dev_err(dc->dev, "failed to get pll_d2_out0: %d\n", err); - return err; + goto err_put_node; } } dc->rgb = >output; return 0; + +err_put_node: + of_node_put(np); + return err; } int tegra_dc_rgb_remove(struct tegra_dc *dc) -- 2.25.1
[PATCH] drm/tegra: dc: rgb: Fix refcount leak in tegra_dc_rgb_probe
of_get_child_by_name() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. So add of_node_put() in error paths. Fixes: format:d8f4a9eda006 ("drm: Add NVIDIA Tegra20 support") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/tegra/rgb.c | 31 +-- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c index ff8fce36d2aa..cef2b1b72385 100644 --- a/drivers/gpu/drm/tegra/rgb.c +++ b/drivers/gpu/drm/tegra/rgb.c @@ -196,12 +196,16 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc) int err; np = of_get_child_by_name(dc->dev->of_node, "rgb"); - if (!np || !of_device_is_available(np)) - return -ENODEV; + if (!np || !of_device_is_available(np)) { + err = -ENODEV; + goto err_put_node; + } rgb = devm_kzalloc(dc->dev, sizeof(*rgb), GFP_KERNEL); - if (!rgb) - return -ENOMEM; + if (!rgb) { + err = -ENOMEM; + goto err_put_node; + } rgb->output.dev = dc->dev; rgb->output.of_node = np; @@ -209,31 +213,34 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc) err = tegra_output_probe(>output); if (err < 0) - return err; + goto err_put_node; + rgb->clk = devm_clk_get(dc->dev, NULL); if (IS_ERR(rgb->clk)) { dev_err(dc->dev, "failed to get clock\n"); - return PTR_ERR(rgb->clk); + err = PTR_ERR(rgb->clk); + goto err_put_node; } rgb->clk_parent = devm_clk_get(dc->dev, "parent"); if (IS_ERR(rgb->clk_parent)) { dev_err(dc->dev, "failed to get parent clock\n"); - return PTR_ERR(rgb->clk_parent); + err = PTR_ERR(rgb->clk_parent); + goto err_put_node; } err = clk_set_parent(rgb->clk, rgb->clk_parent); if (err < 0) { dev_err(dc->dev, "failed to set parent clock: %d\n", err); - return err; + goto err_put_node; } rgb->pll_d_out0 = clk_get_sys(NULL, "pll_d_out0"); if (IS_ERR(rgb->pll_d_out0)) { err = PTR_ERR(rgb->pll_d_out0); dev_err(dc->dev, "failed to get pll_d_out0: %d\n", err); - return err; + goto err_put_node; } if (dc->soc->has_pll_d2_out0) { @@ -241,13 +248,17 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc) if (IS_ERR(rgb->pll_d2_out0)) { err = PTR_ERR(rgb->pll_d2_out0); dev_err(dc->dev, "failed to get pll_d2_out0: %d\n", err); - return err; + goto err_put_node; } } dc->rgb = >output; return 0; + +err_put_node: + of_node_put(np); + return err; } int tegra_dc_rgb_remove(struct tegra_dc *dc) -- 2.25.1
[PATCH v2] drm/virtio: Fix NULL vs IS_ERR checking in virtio_gpu_object_shmem_init
Since drm_prime_pages_to_sg() function return error pointers. The drm_gem_shmem_get_sg_table() function returns error pointers too. Using IS_ERR() to check the return value to fix this. Fixes: 2f2aa13724d5 ("drm/virtio: move virtio_gpu_mem_entry initialization to new function") Signed-off-by: Miaoqian Lin --- changes in v2: - Update Fixes tag. - rebase the working tree. v1 Link: https://lore.kernel.org/all/20211222072649.18169-1-linmq...@gmail.com/ --- drivers/gpu/drm/virtio/virtgpu_object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c index f293e6ad52da..1cc8f3fc8e4b 100644 --- a/drivers/gpu/drm/virtio/virtgpu_object.c +++ b/drivers/gpu/drm/virtio/virtgpu_object.c @@ -168,9 +168,9 @@ static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev, * since virtio_gpu doesn't support dma-buf import from other devices. */ shmem->pages = drm_gem_shmem_get_sg_table(>base); - if (!shmem->pages) { + if (IS_ERR(shmem->pages)) { drm_gem_shmem_unpin(>base); - return -EINVAL; + return PTR_ERR(shmem->pages); } if (use_dma_api) { -- 2.25.1
[PATCH v4] drm/v3d/v3d_drv: Fix PM disable depth imbalance
The pm_runtime_enable will increase power disable depth. We need to call pm_runtime_disable() to balance it when needed use devm_pm_runtime_enable() and handle it automatically/ Fixes: 57692c94dcbe ("drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+") Signed-off-by: Miaoqian Lin --- Changes in v4: - use devm_pm_runtime_enable() Changes in v3: - call pm_runtime_disable() in v3d_platform_drm_remove - update commit message Changes in v2 - put pm_runtime_disable before dma_free_wc - rename dma_free to pm_disable v1: https://lore.kernel.org/r/20220105120442.14418-1-linmq...@gmail.com v2: https://lore.kernel.org/r/20220106124657.32737-1-linmq...@gmail.com v3: https://lore.kernel.org/all/20220601122050.1822-1-linmq...@gmail.com --- drivers/gpu/drm/v3d/v3d_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/v3d_drv.c index 1afcd54fbbd5..563ad4b9c2e8 100644 --- a/drivers/gpu/drm/v3d/v3d_drv.c +++ b/drivers/gpu/drm/v3d/v3d_drv.c @@ -282,7 +282,9 @@ static int v3d_platform_drm_probe(struct platform_device *pdev) pm_runtime_use_autosuspend(dev); pm_runtime_set_autosuspend_delay(dev, 50); - pm_runtime_enable(dev); + ret = devm_pm_runtime_enable(dev); + if (ret) + goto dma_free; ret = v3d_gem_init(drm); if (ret) -- 2.25.1
Re: [PATCH v3] drm/v3d/v3d_drv: Fix PM disable depth imbalance
Hi, Thierry On 2022/6/1 22:47, Thierry Reding wrote: > On Wed, Jun 01, 2022 at 09:55:02PM +0800, Miaoqian Lin wrote: >> Hi, Daniel >> >> On 2022/6/1 21:26, Daniel Vetter wrote: >>> On Wed, Jun 01, 2022 at 04:20:50PM +0400, Miaoqian Lin wrote: >>>> The pm_runtime_enable will increase power disable depth. >>>> If the probe fails, we should use pm_runtime_disable() to balance >>>> pm_runtime_enable(). >>>> Also call disable function in remove function. >>>> >>>> Fixes: 57692c94dcbe ("drm/v3d: Introduce a new DRM driver for Broadcom V3D >>>> V3.x+") >>>> Signed-off-by: Miaoqian Lin >>>> --- >>>> Changes in v3: >>>> - call pm_runtime_disable() in v3d_platform_drm_remove >>>> - update commit message >>>> >>>> Changes in v2 >>>> - put pm_runtime_disable before dma_free_wc >>>> - rename dma_free to pm_disable >>>> >>>> v1: https://lore.kernel.org/r/20220105120442.14418-1-linmq...@gmail.com >>>> v2: https://lore.kernel.org/r/20220106124657.32737-1-linmq...@gmail.com >>> Maybe a bit late since we're at v3 already, but are there no devm_ >>> functions here that would dtrt automatically? >> Sorry I don't see one, or we can use devm_add_action_or_reset() to add >> handling >> >> action. something like disp_cc_sm8250_probe() in >> drivers/clk/qcom/dispcc-sm8250.c >> >> How do you think? > Looks like there's a devm_pm_runtime_enable() helper that does exactly > that. See commit b3636a3a2c51 ("PM: runtime: add devm_pm_runtime_enable > helper"). I haven't seen any large janitorial series yet for that, so > perhaps it's just not widely known yet. Great, very helpful. Thanks for your kind reminder. > Thierry
Re: [PATCH v3] drm/v3d/v3d_drv: Fix PM disable depth imbalance
Hi, Daniel On 2022/6/1 21:26, Daniel Vetter wrote: > On Wed, Jun 01, 2022 at 04:20:50PM +0400, Miaoqian Lin wrote: >> The pm_runtime_enable will increase power disable depth. >> If the probe fails, we should use pm_runtime_disable() to balance >> pm_runtime_enable(). >> Also call disable function in remove function. >> >> Fixes: 57692c94dcbe ("drm/v3d: Introduce a new DRM driver for Broadcom V3D >> V3.x+") >> Signed-off-by: Miaoqian Lin >> --- >> Changes in v3: >> - call pm_runtime_disable() in v3d_platform_drm_remove >> - update commit message >> >> Changes in v2 >> - put pm_runtime_disable before dma_free_wc >> - rename dma_free to pm_disable >> >> v1: https://lore.kernel.org/r/20220105120442.14418-1-linmq...@gmail.com >> v2: https://lore.kernel.org/r/20220106124657.32737-1-linmq...@gmail.com > Maybe a bit late since we're at v3 already, but are there no devm_ > functions here that would dtrt automatically? Sorry I don't see one, or we can use devm_add_action_or_reset() to add handling action. something like disp_cc_sm8250_probe() in drivers/clk/qcom/dispcc-sm8250.c How do you think? > Or is there another reason > we can't use them? > -Daniel >> --- >> drivers/gpu/drm/v3d/v3d_drv.c | 6 -- >> 1 file changed, 4 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/v3d_drv.c >> index 1afcd54fbbd5..f3380399fe17 100644 >> --- a/drivers/gpu/drm/v3d/v3d_drv.c >> +++ b/drivers/gpu/drm/v3d/v3d_drv.c >> @@ -286,7 +286,7 @@ static int v3d_platform_drm_probe(struct platform_device >> *pdev) >> >> ret = v3d_gem_init(drm); >> if (ret) >> -goto dma_free; >> +goto pm_disable; >> >> ret = v3d_irq_init(v3d); >> if (ret) >> @@ -302,7 +302,8 @@ static int v3d_platform_drm_probe(struct platform_device >> *pdev) >> v3d_irq_disable(v3d); >> gem_destroy: >> v3d_gem_destroy(drm); >> -dma_free: >> +pm_disable: >> +pm_runtime_disable(dev); >> dma_free_wc(dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr); >> return ret; >> } >> @@ -316,6 +317,7 @@ static int v3d_platform_drm_remove(struct >> platform_device *pdev) >> >> v3d_gem_destroy(drm); >> >> +pm_runtime_disable(>dev); >> dma_free_wc(v3d->drm.dev, 4096, v3d->mmu_scratch, >> v3d->mmu_scratch_paddr); >> >> -- >> 2.25.1 >>
[RESEND PATCH] drm/mipi-dsi: Fix error handling in mipi_dsi_device_register_full
In mipi_dsi_device_alloc(), it calls device_initialize(>dev); We need to use put_device() instead freeing directly. Fixes: 068a002 ("drm: Add MIPI DSI bus support") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/drm_mipi_dsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c index c40bde96cfdf..8cc8deca006f 100644 --- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c @@ -228,7 +228,7 @@ mipi_dsi_device_register_full(struct mipi_dsi_host *host, ret = mipi_dsi_device_add(dsi); if (ret) { drm_err(host, "failed to add DSI device %d\n", ret); - kfree(dsi); + put_device(>dev); return ERR_PTR(ret); } -- 2.25.1
[PATCH v3] drm/v3d/v3d_drv: Fix PM disable depth imbalance
The pm_runtime_enable will increase power disable depth. If the probe fails, we should use pm_runtime_disable() to balance pm_runtime_enable(). Also call disable function in remove function. Fixes: 57692c94dcbe ("drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+") Signed-off-by: Miaoqian Lin --- Changes in v3: - call pm_runtime_disable() in v3d_platform_drm_remove - update commit message Changes in v2 - put pm_runtime_disable before dma_free_wc - rename dma_free to pm_disable v1: https://lore.kernel.org/r/20220105120442.14418-1-linmq...@gmail.com v2: https://lore.kernel.org/r/20220106124657.32737-1-linmq...@gmail.com --- drivers/gpu/drm/v3d/v3d_drv.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/v3d_drv.c index 1afcd54fbbd5..f3380399fe17 100644 --- a/drivers/gpu/drm/v3d/v3d_drv.c +++ b/drivers/gpu/drm/v3d/v3d_drv.c @@ -286,7 +286,7 @@ static int v3d_platform_drm_probe(struct platform_device *pdev) ret = v3d_gem_init(drm); if (ret) - goto dma_free; + goto pm_disable; ret = v3d_irq_init(v3d); if (ret) @@ -302,7 +302,8 @@ static int v3d_platform_drm_probe(struct platform_device *pdev) v3d_irq_disable(v3d); gem_destroy: v3d_gem_destroy(drm); -dma_free: +pm_disable: + pm_runtime_disable(dev); dma_free_wc(dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr); return ret; } @@ -316,6 +317,7 @@ static int v3d_platform_drm_remove(struct platform_device *pdev) v3d_gem_destroy(drm); + pm_runtime_disable(>dev); dma_free_wc(v3d->drm.dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr); -- 2.25.1
[PATCH v2 2/2] drm/meson: encoder_hdmi: Fix refcount leak in meson_encoder_hdmi_init
of_graph_get_remote_node() returns remote device nodepointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak. Fixes: e67f6037ae1b ("drm/meson: split out encoder from meson_dw_hdmi") Signed-off-by: Miaoqian Lin --- changes in v2: - call of_node_put() after of_find_device_by_node() and error paths before of_find_device_by_node(); --- drivers/gpu/drm/meson/meson_encoder_hdmi.c | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/meson/meson_encoder_hdmi.c b/drivers/gpu/drm/meson/meson_encoder_hdmi.c index 5e306de6f485..0d532e8e8cca 100644 --- a/drivers/gpu/drm/meson/meson_encoder_hdmi.c +++ b/drivers/gpu/drm/meson/meson_encoder_hdmi.c @@ -365,7 +365,8 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) meson_encoder_hdmi->next_bridge = of_drm_find_bridge(remote); if (!meson_encoder_hdmi->next_bridge) { dev_err(priv->dev, "Failed to find HDMI transceiver bridge\n"); - return -EPROBE_DEFER; + ret = -EPROBE_DEFER; + goto err_put_node; } /* HDMI Encoder Bridge */ @@ -383,7 +384,7 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) DRM_MODE_ENCODER_TMDS); if (ret) { dev_err(priv->dev, "Failed to init HDMI encoder: %d\n", ret); - return ret; + goto err_put_node; } meson_encoder_hdmi->encoder.possible_crtcs = BIT(0); @@ -393,7 +394,7 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) DRM_BRIDGE_ATTACH_NO_CONNECTOR); if (ret) { dev_err(priv->dev, "Failed to attach bridge: %d\n", ret); - return ret; + goto err_put_node; } /* Initialize & attach Bridge Connector */ @@ -401,7 +402,8 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) _encoder_hdmi->encoder); if (IS_ERR(meson_encoder_hdmi->connector)) { dev_err(priv->dev, "Unable to create HDMI bridge connector\n"); - return PTR_ERR(meson_encoder_hdmi->connector); + ret = PTR_ERR(meson_encoder_hdmi->connector); + goto err_put_node; } drm_connector_attach_encoder(meson_encoder_hdmi->connector, _encoder_hdmi->encoder); @@ -428,6 +430,7 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) meson_encoder_hdmi->connector->ycbcr_420_allowed = true; pdev = of_find_device_by_node(remote); + of_node_put(remote); if (pdev) { struct cec_connector_info conn_info; struct cec_notifier *notifier; @@ -444,4 +447,8 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) dev_dbg(priv->dev, "HDMI encoder initialized\n"); return 0; + +err_put_node: + of_node_put(remote); + return ret; } -- 2.25.1
[PATCH v2 1/2] drm/meson: encoder_cvbs: Fix refcount leak in meson_encoder_cvbs_init
of_graph_get_remote_node() returns remote device nodepointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak. Fixes: 318ba02cd8a8 ("drm/meson: encoder_cvbs: switch to bridge with ATTACH_NO_CONNECTOR") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/meson/meson_encoder_cvbs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/meson/meson_encoder_cvbs.c b/drivers/gpu/drm/meson/meson_encoder_cvbs.c index fd8db97ba8ba..8110a6e39320 100644 --- a/drivers/gpu/drm/meson/meson_encoder_cvbs.c +++ b/drivers/gpu/drm/meson/meson_encoder_cvbs.c @@ -238,6 +238,7 @@ int meson_encoder_cvbs_init(struct meson_drm *priv) } meson_encoder_cvbs->next_bridge = of_drm_find_bridge(remote); + of_node_put(remote); if (!meson_encoder_cvbs->next_bridge) { dev_err(priv->dev, "Failed to find CVBS Connector bridge\n"); return -EPROBE_DEFER; -- 2.25.1
[PATCH v2 0/2] drm/meson: Fix refcount leak
The following patchset fix two refcount leak bugs. The cause of the bugs are missing of_node_put() after of_graph_get_remote_node(). changes in v2: - patch#2:Fixed patch in meson_encoder_hdmi_init, call of_node_put() after of_find_device_by_node() and error paths before that. noted by Martin Blumenstingl (patch#1: no changes since v1) v1 link: patch#1: https://lore.kernel.org/r/20220531144818.26943-1-linmq...@gmail.com/ patch#2: https://lore.kernel.org/r/20220531144818.26943-2-linmq...@gmail.com/ Miaoqian Lin (2): drm/meson: encoder_cvbs: Fix refcount leak in meson_encoder_cvbs_init drm/meson: encoder_hdmi: Fix refcount leak in meson_encoder_hdmi_init drivers/gpu/drm/meson/meson_encoder_cvbs.c | 1 + drivers/gpu/drm/meson/meson_encoder_hdmi.c | 15 +++ 2 files changed, 12 insertions(+), 4 deletions(-) -- 2.25.1
[PATCH 2/2] drm/meson: encoder_hdmi: Fix refcount leak in meson_encoder_hdmi_init
of_graph_get_remote_node() returns remote device nodepointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak. Fixes: e67f6037ae1b ("drm/meson: split out encoder from meson_dw_hdmi") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/meson/meson_encoder_hdmi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/meson/meson_encoder_hdmi.c b/drivers/gpu/drm/meson/meson_encoder_hdmi.c index 5e306de6f485..f3341458f8b7 100644 --- a/drivers/gpu/drm/meson/meson_encoder_hdmi.c +++ b/drivers/gpu/drm/meson/meson_encoder_hdmi.c @@ -363,6 +363,7 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) } meson_encoder_hdmi->next_bridge = of_drm_find_bridge(remote); + of_node_put(remote); if (!meson_encoder_hdmi->next_bridge) { dev_err(priv->dev, "Failed to find HDMI transceiver bridge\n"); return -EPROBE_DEFER; -- 2.25.1
[PATCH 1/2] drm/meson: encoder_cvbs: Fix refcount leak in meson_encoder_cvbs_init
of_graph_get_remote_node() returns remote device nodepointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak. Fixes: 318ba02cd8a8 ("drm/meson: encoder_cvbs: switch to bridge with ATTACH_NO_CONNECTOR") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/meson/meson_encoder_cvbs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/meson/meson_encoder_cvbs.c b/drivers/gpu/drm/meson/meson_encoder_cvbs.c index fd8db97ba8ba..8110a6e39320 100644 --- a/drivers/gpu/drm/meson/meson_encoder_cvbs.c +++ b/drivers/gpu/drm/meson/meson_encoder_cvbs.c @@ -238,6 +238,7 @@ int meson_encoder_cvbs_init(struct meson_drm *priv) } meson_encoder_cvbs->next_bridge = of_drm_find_bridge(remote); + of_node_put(remote); if (!meson_encoder_cvbs->next_bridge) { dev_err(priv->dev, "Failed to find CVBS Connector bridge\n"); return -EPROBE_DEFER; -- 2.25.1
[PATCH] drm/arc: Fix refcount leak in arcpgu_load
of_graph_get_remote_port_parent() returns a node pointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak. Fixes: 3ea66a794fdc ("drm/arc: Inline arcpgu_drm_hdmi_init") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/tiny/arcpgu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c index f0fa3b15c341..6cbc4e9d382e 100644 --- a/drivers/gpu/drm/tiny/arcpgu.c +++ b/drivers/gpu/drm/tiny/arcpgu.c @@ -310,6 +310,7 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu) /* Locate drm bridge from the hdmi encoder DT node */ bridge = of_drm_find_bridge(encoder_node); + of_node_put(encoder_node); if (!bridge) return -EPROBE_DEFER; -- 2.25.1
[PATCH] drm/mcde: Fix refcount leak in mcde_dsi_bind
Every iteration of for_each_available_child_of_node() decrements the reference counter of the previous node. There is no decrement when break out from the loop and results in refcount leak. Add missing of_node_put() to fix this. Fixes: 5fc537bfd000 ("drm/mcde: Add new driver for ST-Ericsson MCDE") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/mcde/mcde_dsi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/mcde/mcde_dsi.c b/drivers/gpu/drm/mcde/mcde_dsi.c index 5651734ce977..9f9ac8699310 100644 --- a/drivers/gpu/drm/mcde/mcde_dsi.c +++ b/drivers/gpu/drm/mcde/mcde_dsi.c @@ -,6 +,7 @@ static int mcde_dsi_bind(struct device *dev, struct device *master, bridge = of_drm_find_bridge(child); if (!bridge) { dev_err(dev, "failed to find bridge\n"); + of_node_put(child); return -EINVAL; } } -- 2.25.1
[PATCH] drm/msm/a6xx: Fix refcount leak in a6xx_gpu_init
of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. a6xx_gmu_init() passes the node to of_find_device_by_node() and of_dma_configure(), of_find_device_by_node() will takes its reference, of_dma_configure() doesn't need the node after usage. Add missing of_node_put() to avoid refcount leak. Fixes: 4b565ca5a2cb ("drm/msm: Add A6XX device support") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index ccc4fcf7a630..a8f6d73197b1 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -1919,6 +1919,7 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev) BUG_ON(!node); ret = a6xx_gmu_init(a6xx_gpu, node); + of_node_put(node); if (ret) { a6xx_destroy(&(a6xx_gpu->base.base)); return ERR_PTR(ret); -- 2.25.1
[PATCH] video: fbdev: Fix refcount leak in clcdfb_of_vram_setup
of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Add missing of_node_put() to avoid refcount leak. Fixes: d10715be03bd ("video: ARM CLCD: Add DT support") Signed-off-by: Miaoqian Lin --- drivers/video/fbdev/amba-clcd.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/amba-clcd.c b/drivers/video/fbdev/amba-clcd.c index 9ec969e136bf..8080116aea84 100644 --- a/drivers/video/fbdev/amba-clcd.c +++ b/drivers/video/fbdev/amba-clcd.c @@ -758,12 +758,15 @@ static int clcdfb_of_vram_setup(struct clcd_fb *fb) return -ENODEV; fb->fb.screen_base = of_iomap(memory, 0); - if (!fb->fb.screen_base) + if (!fb->fb.screen_base) { + of_node_put(memory); return -ENOMEM; + } fb->fb.fix.smem_start = of_translate_address(memory, of_get_address(memory, 0, , NULL)); fb->fb.fix.smem_len = size; + of_node_put(memory); return 0; } -- 2.25.1
Re: [PATCH] drm/meson: Fix refcount leak in meson_encoder_hdmi_init
Hi, On 2022/5/12 17:32, Neil Armstrong wrote: > Hi, > > On 12/05/2022 11:21, Miaoqian Lin wrote: >> of_find_device_by_node() takes a reference to the embedded struct device, >> we should use put_device() to release it when not need anymore. >> Add missing put_device() in error path to avoid refcount leak. >> >> Fixes: 0af5e0b41110 ("drm/meson: encoder_hdmi: switch to bridge >> DRM_BRIDGE_ATTACH_NO_CONNECTOR") >> Signed-off-by: Miaoqian Lin > > You already sent the same patch yesterday, please avoid this. > Sorry for the mistake, I realized this after I sent it. I will be more careful. > Neil > >> --- >> drivers/gpu/drm/meson/meson_encoder_hdmi.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/gpu/drm/meson/meson_encoder_hdmi.c >> b/drivers/gpu/drm/meson/meson_encoder_hdmi.c >> index 5e306de6f485..de87f02cd388 100644 >> --- a/drivers/gpu/drm/meson/meson_encoder_hdmi.c >> +++ b/drivers/gpu/drm/meson/meson_encoder_hdmi.c >> @@ -435,8 +435,10 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) >> cec_fill_conn_info_from_drm(_info, >> meson_encoder_hdmi->connector); >> notifier = cec_notifier_conn_register(>dev, NULL, >> _info); >> - if (!notifier) >> + if (!notifier) { >> + put_device(>dev); >> return -ENOMEM; >> + } >> meson_encoder_hdmi->cec_notifier = notifier; >> } >
[PATCH] drm/meson: Fix refcount leak in meson_encoder_hdmi_init
of_find_device_by_node() takes a reference to the embedded struct device, we should use put_device() to release it when not need anymore. Add missing put_device() in error path to avoid refcount leak. Fixes: 0af5e0b41110 ("drm/meson: encoder_hdmi: switch to bridge DRM_BRIDGE_ATTACH_NO_CONNECTOR") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/meson/meson_encoder_hdmi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/meson/meson_encoder_hdmi.c b/drivers/gpu/drm/meson/meson_encoder_hdmi.c index 5e306de6f485..de87f02cd388 100644 --- a/drivers/gpu/drm/meson/meson_encoder_hdmi.c +++ b/drivers/gpu/drm/meson/meson_encoder_hdmi.c @@ -435,8 +435,10 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) cec_fill_conn_info_from_drm(_info, meson_encoder_hdmi->connector); notifier = cec_notifier_conn_register(>dev, NULL, _info); - if (!notifier) + if (!notifier) { + put_device(>dev); return -ENOMEM; + } meson_encoder_hdmi->cec_notifier = notifier; } -- 2.25.1
[PATCH] drm/meson: Fix refcount leak in meson_encoder_hdmi_init
of_find_device_by_node() takes reference, we should use put_device() to release it when not need anymore. Add missing put_device() in error path to avoid refcount leak. Fixes: 0af5e0b41110 ("drm/meson: encoder_hdmi: switch to bridge DRM_BRIDGE_ATTACH_NO_CONNECTOR") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/meson/meson_encoder_hdmi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/meson/meson_encoder_hdmi.c b/drivers/gpu/drm/meson/meson_encoder_hdmi.c index 5e306de6f485..de87f02cd388 100644 --- a/drivers/gpu/drm/meson/meson_encoder_hdmi.c +++ b/drivers/gpu/drm/meson/meson_encoder_hdmi.c @@ -435,8 +435,10 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) cec_fill_conn_info_from_drm(_info, meson_encoder_hdmi->connector); notifier = cec_notifier_conn_register(>dev, NULL, _info); - if (!notifier) + if (!notifier) { + put_device(>dev); return -ENOMEM; + } meson_encoder_hdmi->cec_notifier = notifier; } -- 2.25.1
[PATCH] drm/amd/display: Fix memory leak in dcn21_clock_source_create
When dcn20_clk_src_construct() fails, we need to release clk_src. Fixes: 6f4e6361c3ff ("drm/amd/display: Add Renoir resource (v2)") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c index 3fe4bfbb98a0..faab59508d82 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c @@ -997,6 +997,7 @@ static struct clock_source *dcn21_clock_source_create( return _src->base; } + kfree(clk_src); BREAK_TO_DEBUGGER(); return NULL; } -- 2.17.1
[PATCH v3] drm/vc4: Use pm_runtime_resume_and_get to fix pm_runtime_get_sync() usage
If the device is already in a runtime PM enabled state pm_runtime_get_sync() will return 1. Also, we need to call pm_runtime_put_noidle() when pm_runtime_get_sync() fails, so use pm_runtime_resume_and_get() instead. this function will handle this. Fixes: 4078f5757144 ("drm/vc4: Add DSI driver") Signed-off-by: Miaoqian Lin --- change in v2: - switch to pm_runtime_resume_and_get() to fix refcount leak. changes in v3: - keep the original checking way for retval. --- drivers/gpu/drm/vc4/vc4_dsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c index 752f921735c6..98308a17e4ed 100644 --- a/drivers/gpu/drm/vc4/vc4_dsi.c +++ b/drivers/gpu/drm/vc4/vc4_dsi.c @@ -846,7 +846,7 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) unsigned long phy_clock; int ret; - ret = pm_runtime_get_sync(dev); + ret = pm_runtime_resume_and_get(dev); if (ret) { DRM_ERROR("Failed to runtime PM enable on DSI%d\n", dsi->variant->port); return; -- 2.17.1
Re: [PATCH v2] drm/vc4: Fix pm_runtime_get_sync() usage
On 2022/4/20 15:51, Maxime Ripard wrote: > On Wed, Apr 20, 2022 at 12:49:48AM +0000, Miaoqian Lin wrote: >> If the device is already in a runtime PM enabled state >> pm_runtime_get_sync() will return 1, so a test for negative >> value should be used to check for errors. >> >> Also, we need to call pm_runtime_put_noidle() when pm_runtime_get_sync() >> fails, so use pm_runtime_resume_and_get() instead. this function >> will handle this. >> >> Fixes: 4078f5757144 ("drm/vc4: Add DSI driver") >> Signed-off-by: Miaoqian Lin >> --- >> change in v2: >> - switch to pm_runtime_resume_and_get() to fix refcount leak. >> --- >> drivers/gpu/drm/vc4/vc4_dsi.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c >> index 752f921735c6..9d7ffaf6bc70 100644 >> --- a/drivers/gpu/drm/vc4/vc4_dsi.c >> +++ b/drivers/gpu/drm/vc4/vc4_dsi.c >> @@ -846,8 +846,8 @@ static void vc4_dsi_encoder_enable(struct drm_encoder >> *encoder) >> unsigned long phy_clock; >> int ret; >> >> -ret = pm_runtime_get_sync(dev); >> -if (ret) { >> +ret = pm_runtime_resume_and_get(dev); >> +if (ret < 0) { > pm_runtime_resume_and_get will return 0 on success, so the previous check was > correct previous check is for pm_runtime_get_sync() not for pm_runtime_resume_and_get (), I switch to pm_runtime_resume_and_get() to fix the refcount leak bug at the same time. Sure it's ok to use check if(ret) to check the retval, I just follow a more common way for usage of pm_runtime_resume_and_get() in the codebase—— check ret<0 Since pm_runtime_resume_and_get() return negative error code. > Maxime
[PATCH v2] drm/bridge: Fix error handling in analogix_dp_probe
In the error handling path, the clk_prepare_enable() function call should be balanced by a corresponding 'clk_disable_unprepare()' call , as already done in the remove function. Fixes: 3424e3a4f844 ("drm: bridge: analogix/dp: split exynos dp driver to bridge directory") Signed-off-by: Miaoqian Lin --- changes in v2: - remove the wrong return statement. --- .../gpu/drm/bridge/analogix/analogix_dp_core.c | 18 +- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c index eb590fb8e8d0..474ef88015ae 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c @@ -1698,8 +1698,10 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); dp->reg_base = devm_ioremap_resource(>dev, res); - if (IS_ERR(dp->reg_base)) - return ERR_CAST(dp->reg_base); + if (IS_ERR(dp->reg_base)) { + ret = PTR_ERR(dp->reg_base); + goto err_disable_clk; + } dp->force_hpd = of_property_read_bool(dev->of_node, "force-hpd"); @@ -1711,7 +1713,8 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) if (IS_ERR(dp->hpd_gpiod)) { dev_err(dev, "error getting HDP GPIO: %ld\n", PTR_ERR(dp->hpd_gpiod)); - return ERR_CAST(dp->hpd_gpiod); + ret = PTR_ERR(dp->hpd_gpiod); + goto err_disable_clk; } if (dp->hpd_gpiod) { @@ -1731,7 +1734,8 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) if (dp->irq == -ENXIO) { dev_err(>dev, "failed to get irq\n"); - return ERR_PTR(-ENODEV); + ret = -ENODEV; + goto err_disable_clk; } ret = devm_request_threaded_irq(>dev, dp->irq, @@ -1740,11 +1744,15 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) irq_flags, "analogix-dp", dp); if (ret) { dev_err(>dev, "failed to request irq\n"); - return ERR_PTR(ret); + goto err_disable_clk; } disable_irq(dp->irq); return dp; + +err_disable_clk: + clk_disable_unprepare(dp->clock); + return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(analogix_dp_probe); -- 2.17.1
[PATCH v2] drm/vc4: Fix pm_runtime_get_sync() usage
If the device is already in a runtime PM enabled state pm_runtime_get_sync() will return 1, so a test for negative value should be used to check for errors. Also, we need to call pm_runtime_put_noidle() when pm_runtime_get_sync() fails, so use pm_runtime_resume_and_get() instead. this function will handle this. Fixes: 4078f5757144 ("drm/vc4: Add DSI driver") Signed-off-by: Miaoqian Lin --- change in v2: - switch to pm_runtime_resume_and_get() to fix refcount leak. --- drivers/gpu/drm/vc4/vc4_dsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c index 752f921735c6..9d7ffaf6bc70 100644 --- a/drivers/gpu/drm/vc4/vc4_dsi.c +++ b/drivers/gpu/drm/vc4/vc4_dsi.c @@ -846,8 +846,8 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) unsigned long phy_clock; int ret; - ret = pm_runtime_get_sync(dev); - if (ret) { + ret = pm_runtime_resume_and_get(dev); + if (ret < 0) { DRM_ERROR("Failed to runtime PM enable on DSI%d\n", dsi->variant->port); return; } -- 2.17.1
[PATCH] drm/armada: Fix a potential double free in armada_drm_bind
priv is a managed resource allocated with devm_drm_dev_alloc(), so there is no need to call kfree() explicitly or there will be a double free. Fixes: 90ad200b4cbc ("drm/armada: Use devm_drm_dev_alloc") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/armada/armada_drv.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c index 0643887800b4..142668cd6d7c 100644 --- a/drivers/gpu/drm/armada/armada_drv.c +++ b/drivers/gpu/drm/armada/armada_drv.c @@ -99,7 +99,6 @@ static int armada_drm_bind(struct device *dev) if (ret) { dev_err(dev, "[" DRM_NAME ":%s] can't kick out simple-fb: %d\n", __func__, ret); - kfree(priv); return ret; } -- 2.17.1
[PATCH] drm/vc4: Fix pm_runtime_get_sync() error checking
If the device is already in a runtime PM enabled state pm_runtime_get_sync() will return 1, so a test for negative value should be used to check for errors. Fixes: 4078f5757144 ("drm/vc4: Add DSI driver") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/vc4/vc4_dsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c index 752f921735c6..26aa7d1fa421 100644 --- a/drivers/gpu/drm/vc4/vc4_dsi.c +++ b/drivers/gpu/drm/vc4/vc4_dsi.c @@ -847,7 +847,7 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) int ret; ret = pm_runtime_get_sync(dev); - if (ret) { + if (ret < 0) { DRM_ERROR("Failed to runtime PM enable on DSI%d\n", dsi->variant->port); return; } -- 2.17.1
[PATCH] drm/bridge: Fix error handling in analogix_dp_probe
In the error handling path, the clk_prepare_enable() function call should be balanced by a corresponding 'clk_disable_unprepare()' call , as already done in the remove function. Fixes: 3424e3a4f844 ("drm: bridge: analogix/dp: split exynos dp driver to bridge directory") Signed-off-by: Miaoqian Lin --- .../gpu/drm/bridge/analogix/analogix_dp_core.c | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c index eb590fb8e8d0..2c0f582b4d32 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c @@ -1698,7 +1698,10 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); dp->reg_base = devm_ioremap_resource(>dev, res); - if (IS_ERR(dp->reg_base)) + if (IS_ERR(dp->reg_base)) { + ret = PTR_ERR(dp->reg_base); + goto err_disable_clk; + } return ERR_CAST(dp->reg_base); dp->force_hpd = of_property_read_bool(dev->of_node, "force-hpd"); @@ -1711,7 +1714,8 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) if (IS_ERR(dp->hpd_gpiod)) { dev_err(dev, "error getting HDP GPIO: %ld\n", PTR_ERR(dp->hpd_gpiod)); - return ERR_CAST(dp->hpd_gpiod); + ret = PTR_ERR(dp->hpd_gpiod); + goto err_disable_clk; } if (dp->hpd_gpiod) { @@ -1731,7 +1735,8 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) if (dp->irq == -ENXIO) { dev_err(>dev, "failed to get irq\n"); - return ERR_PTR(-ENODEV); + ret = -ENODEV; + goto err_disable_clk; } ret = devm_request_threaded_irq(>dev, dp->irq, @@ -1740,11 +1745,15 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) irq_flags, "analogix-dp", dp); if (ret) { dev_err(>dev, "failed to request irq\n"); - return ERR_PTR(ret); + goto err_disable_clk; } disable_irq(dp->irq); return dp; + +err_disable_clk: + clk_disable_unprepare(dp->clock); + return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(analogix_dp_probe); -- 2.17.1
[PATCH] omapfb: Add missing of_node_put() in dvic_probe_of
The device_node pointer is returned by of_parse_phandle() with refcount incremented. We should use of_node_put() on it when done. Fixes: f76ee892a99e ("omapfb: copy omapdss & displays for omapfb") Signed-off-by: Miaoqian Lin --- drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c b/drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c index 2fa436475b40..c8ad3ef42bd3 100644 --- a/drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c +++ b/drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c @@ -246,6 +246,7 @@ static int dvic_probe_of(struct platform_device *pdev) adapter_node = of_parse_phandle(node, "ddc-i2c-bus", 0); if (adapter_node) { adapter = of_get_i2c_adapter_by_node(adapter_node); + of_node_put(adapter_node); if (adapter == NULL) { dev_err(>dev, "failed to parse ddc-i2c-bus\n"); omap_dss_put_device(ddata->in); -- 2.17.1
[PATCH v2] drm/i915/selftests: Fix NULL vs IS_ERR checking for kernel_context
Since i915_gem_create_context() function return error pointers, the kernel_context() function does not return null, It returns error pointers too. Using IS_ERR() to check the return value to fix this. Signed-off-by: Miaoqian Lin --- Changes in v2: - clean up unneeded initialization of err. --- drivers/gpu/drm/i915/gt/selftest_execlists.c | 43 ++-- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/selftest_execlists.c b/drivers/gpu/drm/i915/gt/selftest_execlists.c index b367ecfa42de..0d453ddcede4 100644 --- a/drivers/gpu/drm/i915/gt/selftest_execlists.c +++ b/drivers/gpu/drm/i915/gt/selftest_execlists.c @@ -1531,7 +1531,7 @@ static int live_busywait_preempt(void *arg) struct drm_i915_gem_object *obj; struct i915_vma *vma; enum intel_engine_id id; - int err = -ENOMEM; + int err; u32 *map; /* @@ -1540,13 +1540,16 @@ static int live_busywait_preempt(void *arg) */ ctx_hi = kernel_context(gt->i915, NULL); - if (!ctx_hi) - return -ENOMEM; + if (IS_ERR(ctx_hi)) + return IS_ERR(ctx_hi); + ctx_hi->sched.priority = I915_CONTEXT_MAX_USER_PRIORITY; ctx_lo = kernel_context(gt->i915, NULL); - if (!ctx_lo) + if (IS_ERR(ctx_lo)) { + err = PTR_ERR(ctx_lo); goto err_ctx_hi; + } ctx_lo->sched.priority = I915_CONTEXT_MIN_USER_PRIORITY; obj = i915_gem_object_create_internal(gt->i915, PAGE_SIZE); @@ -1742,13 +1745,17 @@ static int live_preempt(void *arg) goto err_spin_hi; ctx_hi = kernel_context(gt->i915, NULL); - if (!ctx_hi) + if (IS_ERR(ctx_hi)) { + err = PTR_ERR(ctx_hi); goto err_spin_lo; + } ctx_hi->sched.priority = I915_CONTEXT_MAX_USER_PRIORITY; ctx_lo = kernel_context(gt->i915, NULL); - if (!ctx_lo) + if (IS_ERR(ctx_lo)) { + err = PTR_ERR(ctx_lo); goto err_ctx_hi; + } ctx_lo->sched.priority = I915_CONTEXT_MIN_USER_PRIORITY; for_each_engine(engine, gt, id) { @@ -1834,12 +1841,16 @@ static int live_late_preempt(void *arg) goto err_spin_hi; ctx_hi = kernel_context(gt->i915, NULL); - if (!ctx_hi) + if (IS_ERR(ctx_hi)) { + err = PTR_ERR(ctx_hi); goto err_spin_lo; + } ctx_lo = kernel_context(gt->i915, NULL); - if (!ctx_lo) + if (IS_ERR(ctx_lo)) { + err = PTR_ERR(ctx_lo); goto err_ctx_hi; + } /* Make sure ctx_lo stays before ctx_hi until we trigger preemption. */ ctx_lo->sched.priority = 1; @@ -1928,8 +1939,8 @@ struct preempt_client { static int preempt_client_init(struct intel_gt *gt, struct preempt_client *c) { c->ctx = kernel_context(gt->i915, NULL); - if (!c->ctx) - return -ENOMEM; + if (IS_ERR(c->ctx)) + return PTR_ERR(c->ctx); if (igt_spinner_init(>spin, gt)) goto err_ctx; @@ -3385,13 +3396,17 @@ static int live_preempt_timeout(void *arg) return -ENOMEM; ctx_hi = kernel_context(gt->i915, NULL); - if (!ctx_hi) + if (IS_ERR(ctx_hi)) { + err = PTR_ERR(ctx_hi); goto err_spin_lo; + } ctx_hi->sched.priority = I915_CONTEXT_MAX_USER_PRIORITY; ctx_lo = kernel_context(gt->i915, NULL); - if (!ctx_lo) + if (IS_ERR(ctx_lo)) { + err = PTR_ERR(ctx_lo); goto err_ctx_hi; + } ctx_lo->sched.priority = I915_CONTEXT_MIN_USER_PRIORITY; for_each_engine(engine, gt, id) { @@ -3683,8 +3698,10 @@ static int live_preempt_smoke(void *arg) for (n = 0; n < smoke.ncontext; n++) { smoke.contexts[n] = kernel_context(smoke.gt->i915, NULL); - if (!smoke.contexts[n]) + if (IS_ERR(smoke.contexts[n])) { + err = PTR_ERR(smoke.contexts[n]); goto err_ctx; + } } for (n = 0; n < ARRAY_SIZE(phase); n++) { -- 2.17.1
[PATCH] drm/amdgpu: Fix double free in amdgpu_get_xgmi_hive
Callback function amdgpu_xgmi_hive_release() in kobject_put() calls kfree(hive), So we don't need call kfree(hive) again. Fixes: 7b833d680481 ("drm/amd/amdgpu: fix potential memleak") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c index e8b8f28c2f72..35d4b966ef2c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c @@ -393,7 +393,6 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev) if (ret) { dev_err(adev->dev, "XGMI: failed initializing kobject for xgmi hive\n"); kobject_put(>kobj); - kfree(hive); hive = NULL; goto pro_end; } -- 2.17.1
[PATCH] drm/tegra: Fix reference leak in tegra_dsi_ganged_probe
The reference taken by 'of_find_device_by_node()' must be released when not needed anymore. Add put_device() call to fix this. Fixes: e94236cde4d5 ("drm/tegra: dsi: Add ganged mode support") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/tegra/dsi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c index f46d377f0c30..de1333dc0d86 100644 --- a/drivers/gpu/drm/tegra/dsi.c +++ b/drivers/gpu/drm/tegra/dsi.c @@ -1538,8 +1538,10 @@ static int tegra_dsi_ganged_probe(struct tegra_dsi *dsi) dsi->slave = platform_get_drvdata(gangster); of_node_put(np); - if (!dsi->slave) + if (!dsi->slave) { + put_device(>dev); return -EPROBE_DEFER; + } dsi->slave->master = dsi; } -- 2.17.1
Re: [PATCH v2] drm/v3d: Fix PM disable depth imbalance in v3d_platform_drm_probe
Hi Melissa, On Sun, Jan 09, 2022 at 04:48:17PM -0100, Melissa Wen wrote: > On 01/06, Miaoqian Lin wrote: > > The pm_runtime_enable will increase power disable depth. > > If the probe fails, we should use pm_runtime_disable() to balance > > pm_runtime_enable(). > > > > if (ret) > > - goto dma_free; > > + goto pm_disable; > > > > ret = v3d_irq_init(v3d); > > if (ret) > > @@ -298,7 +298,8 @@ static int v3d_platform_drm_probe(struct > > platform_device *pdev) > > v3d_irq_disable(v3d); > > gem_destroy: > > v3d_gem_destroy(drm); > > -dma_free: > > +pm_disable: > > + pm_runtime_disable(dev); > > Hi, > > I see this pm_runtime_disable balancing is also missing for > v3d_platform_drm_remove(), right? > I think, yes. > > dma_free_wc(dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr); > > return ret; > > } > > -- > > 2.17.1 > >
[PATCH] drm/msm/hdmi: Fix missing put_device() call in msm_hdmi_get_phy
The reference taken by 'of_find_device_by_node()' must be released when not needed anymore. Add the corresponding 'put_device()' in the error handling path. Fixes: e00012b256d4 ("drm/msm/hdmi: Make HDMI core get its PHY") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/msm/hdmi/hdmi.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c index 75b64e6ae035..a439794a32e8 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c @@ -95,10 +95,15 @@ static int msm_hdmi_get_phy(struct hdmi *hdmi) of_node_put(phy_node); - if (!phy_pdev || !hdmi->phy) { + if (!phy_pdev) { DRM_DEV_ERROR(>dev, "phy driver is not ready\n"); return -EPROBE_DEFER; } + if (!hdmi->phy) { + DRM_DEV_ERROR(>dev, "phy driver is not ready\n"); + put_device(_pdev->dev); + return -EPROBE_DEFER; + } hdmi->phy_dev = get_device(_pdev->dev); -- 2.17.1
[PATCH] drm/sun4i: dw-hdmi: Fix missing put_device() call in sun8i_hdmi_phy_get
The reference taken by 'of_find_device_by_node()' must be released when not needed anymore. Add the corresponding 'put_device()' in the error handling path. Fixes: 9bf3797796f5 ("drm/sun4i: dw-hdmi: Make HDMI PHY into a platform device") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c index b64d93da651d..5e2b0175df36 100644 --- a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c +++ b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c @@ -658,8 +658,10 @@ int sun8i_hdmi_phy_get(struct sun8i_dw_hdmi *hdmi, struct device_node *node) return -EPROBE_DEFER; phy = platform_get_drvdata(pdev); - if (!phy) + if (!phy) { + put_device(>dev); return -EPROBE_DEFER; + } hdmi->phy = phy; -- 2.17.1
[PATCH v2] drm/v3d: Fix PM disable depth imbalance in v3d_platform_drm_probe
The pm_runtime_enable will increase power disable depth. If the probe fails, we should use pm_runtime_disable() to balance pm_runtime_enable(). Fixes: 57692c9 ("drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+") Signed-off-by: Miaoqian Lin --- Changes in v2 - put pm_runtime_disable before dma_free_wc - rename dma_free to pm_disable --- drivers/gpu/drm/v3d/v3d_drv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/v3d_drv.c index bd46396a1ae0..7d500dd5314e 100644 --- a/drivers/gpu/drm/v3d/v3d_drv.c +++ b/drivers/gpu/drm/v3d/v3d_drv.c @@ -282,7 +282,7 @@ static int v3d_platform_drm_probe(struct platform_device *pdev) ret = v3d_gem_init(drm); if (ret) - goto dma_free; + goto pm_disable; ret = v3d_irq_init(v3d); if (ret) @@ -298,7 +298,8 @@ static int v3d_platform_drm_probe(struct platform_device *pdev) v3d_irq_disable(v3d); gem_destroy: v3d_gem_destroy(drm); -dma_free: +pm_disable: + pm_runtime_disable(dev); dma_free_wc(dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr); return ret; } -- 2.17.1
Re: [PATCH] phy: mediatek: Fix missing check in mtk_mipi_tx_probe
Hi, Chun-Kuang: On Fri, Dec 31, 2021 at 12:31:33AM +0800, Chun-Kuang Hu wrote: > > diff --git a/drivers/phy/mediatek/phy-mtk-mipi-dsi.c > > b/drivers/phy/mediatek/phy-mtk-mipi-dsi.c > > index 28ad9403c441..67b005d5b9e3 100644 > > --- a/drivers/phy/mediatek/phy-mtk-mipi-dsi.c > > +++ b/drivers/phy/mediatek/phy-mtk-mipi-dsi.c > > @@ -146,6 +146,8 @@ static int mtk_mipi_tx_probe(struct platform_device > > *pdev) > > return -ENOMEM; > > > > mipi_tx->driver_data = of_device_get_match_data(dev); > > + if (!mipi_tx->driver_data) > > I'm confused. mtk_mipi_tx_probe() is called because this device node's > compatible match one in mtk_mipi_tx_match[]. So I think the return > value of of_device_get_match_data(dev) would not be NULL. If this is > true, this checking is redundant. > I think your are right, this checking is redundant. Thanks for your reply. Regards, Miaoqian.
[PATCH] drm/v3d: Fix PM disable depth imbalance in v3d_platform_drm_probe
The pm_runtime_enable will increase power disable depth. If the probe fails, we should use pm_runtime_disable() to balance pm_runtime_enable(). Fixes: 57692c9 ("drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/v3d/v3d_drv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/v3d_drv.c index bd46396a1ae0..4f293aa733b8 100644 --- a/drivers/gpu/drm/v3d/v3d_drv.c +++ b/drivers/gpu/drm/v3d/v3d_drv.c @@ -300,6 +300,8 @@ static int v3d_platform_drm_probe(struct platform_device *pdev) v3d_gem_destroy(drm); dma_free: dma_free_wc(dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr); +pm_disable: + pm_runtime_disable(dev); return ret; } -- 2.17.1
[PATCH] drm/bridge: nwl-dsi: Fix PM disable depth imbalance in nwl_dsi_probe
The pm_runtime_enable will increase power disable depth. Thus a pairing decrement is needed on the error handling path to keep it balanced according to context. Fixes: 44cfc62 ("drm/bridge: Add NWL MIPI DSI host controller support") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/bridge/nwl-dsi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c b/drivers/gpu/drm/bridge/nwl-dsi.c index a7389a0facfb..fc3ad9fab867 100644 --- a/drivers/gpu/drm/bridge/nwl-dsi.c +++ b/drivers/gpu/drm/bridge/nwl-dsi.c @@ -1206,6 +1206,7 @@ static int nwl_dsi_probe(struct platform_device *pdev) ret = nwl_dsi_select_input(dsi); if (ret < 0) { + pm_runtime_disable(dev); mipi_dsi_host_unregister(>dsi_host); return ret; } -- 2.17.1
[PATCH] drm/bridge: Add missing pm_runtime_disable() in __dw_mipi_dsi_probe
If the probe fails, we should use pm_runtime_disable() to balance pm_runtime_enable(). Add missing pm_runtime_disable() for __dw_mipi_dsi_probe. Fixes: 46fc515 ("drm/bridge/synopsys: Add MIPI DSI host controller bridge") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c index e44e18a0112a..56c3fd08c6a0 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c @@ -1199,6 +1199,7 @@ __dw_mipi_dsi_probe(struct platform_device *pdev, ret = mipi_dsi_host_register(>dsi_host); if (ret) { dev_err(dev, "Failed to register MIPI host: %d\n", ret); + pm_runtime_disable(dev); dw_mipi_dsi_debugfs_remove(dsi); return ERR_PTR(ret); } -- 2.17.1
[PATCH] drm/msm/dsi: Fix missing put_device() call in dsi_get_phy
If of_find_device_by_node() succeeds, dsi_get_phy() doesn't a corresponding put_device(). Thus add put_device() to fix the exception handling. Fixes: ec31abf ("drm/msm/dsi: Separate PHY to another platform device") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/msm/dsi/dsi.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c index 75ae3008b68f..35be526e907a 100644 --- a/drivers/gpu/drm/msm/dsi/dsi.c +++ b/drivers/gpu/drm/msm/dsi/dsi.c @@ -40,7 +40,12 @@ static int dsi_get_phy(struct msm_dsi *msm_dsi) of_node_put(phy_node); - if (!phy_pdev || !msm_dsi->phy) { + if (!phy_pdev) { + DRM_DEV_ERROR(>dev, "%s: phy driver is not ready\n", __func__); + return -EPROBE_DEFER; + } + if (!msm_dsi->phy) { + put_device(_pdev->dev); DRM_DEV_ERROR(>dev, "%s: phy driver is not ready\n", __func__); return -EPROBE_DEFER; } -- 2.17.1
[PATCH] drm/mipi-dsi: Fix error handling in mipi_dsi_device_register_full
In mipi_dsi_device_alloc(), it calls device_initialize(>dev); We need to use put_device() instead freeing directly. Fixes: 068a002 ("drm: Add MIPI DSI bus support") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/drm_mipi_dsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c index 18cef04df2f2..609bd9fc1bc5 100644 --- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c @@ -228,7 +228,7 @@ mipi_dsi_device_register_full(struct mipi_dsi_host *host, ret = mipi_dsi_device_add(dsi); if (ret) { drm_err(host, "failed to add DSI device %d\n", ret); - kfree(dsi); + put_device(>dev); return ERR_PTR(ret); } -- 2.17.1
[PATCH] drm/bridge: Fix free wrong object in sii8620_init_rcp_input_dev
rc_dev is allocated by rc_allocate_device(), and doesn't assigned to ctx->rc_dev before calling rc_free_device(ctx->rc_dev). So it should call rc_free_device(rc_dev); Fixes: e25f1f7 ("drm/bridge/sii8620: add remote control support") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/bridge/sil-sii8620.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c index 843265d7f1b1..ec7745c31da0 100644 --- a/drivers/gpu/drm/bridge/sil-sii8620.c +++ b/drivers/gpu/drm/bridge/sil-sii8620.c @@ -2120,7 +2120,7 @@ static void sii8620_init_rcp_input_dev(struct sii8620 *ctx) if (ret) { dev_err(ctx->dev, "Failed to register RC device\n"); ctx->error = ret; - rc_free_device(ctx->rc_dev); + rc_free_device(rc_dev); return; } ctx->rc_dev = rc_dev; -- 2.17.1
[PATCH] phy: mediatek: Fix missing check in mtk_mipi_tx_probe
The of_device_get_match_data() function may return NULL. Add check to prevent potential null dereference. Signed-off-by: Miaoqian Lin --- drivers/phy/mediatek/phy-mtk-mipi-dsi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/phy/mediatek/phy-mtk-mipi-dsi.c b/drivers/phy/mediatek/phy-mtk-mipi-dsi.c index 28ad9403c441..67b005d5b9e3 100644 --- a/drivers/phy/mediatek/phy-mtk-mipi-dsi.c +++ b/drivers/phy/mediatek/phy-mtk-mipi-dsi.c @@ -146,6 +146,8 @@ static int mtk_mipi_tx_probe(struct platform_device *pdev) return -ENOMEM; mipi_tx->driver_data = of_device_get_match_data(dev); + if (!mipi_tx->driver_data) + return -ENODEV; mipi_tx->regs = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(mipi_tx->regs)) -- 2.17.1
[PATCH] drm/bridge: anx7625: Fix null vs IS_ERR() checking in anx7625_register_i2c_dummy_clients
Since i2c_new_client_device() function return error pointers. The i2c_new_dummy_device() function does not return NULL, It returns error pointers too. Using IS_ERR() to check the return value to fix this. Fixes: 8bdfc5dae4e3("drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/bridge/analogix/anx7625.c | 32 --- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c index 1a871f6b6822..eb72aa6aedd6 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -1637,40 +1637,54 @@ static const struct drm_bridge_funcs anx7625_bridge_funcs = { static int anx7625_register_i2c_dummy_clients(struct anx7625_data *ctx, struct i2c_client *client) { + int err = 0; + ctx->i2c.tx_p0_client = i2c_new_dummy_device(client->adapter, TX_P0_ADDR >> 1); - if (!ctx->i2c.tx_p0_client) - return -ENOMEM; + if (IS_ERR(ctx->i2c.tx_p0_client)) + return PTR_ERR(ctx->i2c.tx_p0_client); ctx->i2c.tx_p1_client = i2c_new_dummy_device(client->adapter, TX_P1_ADDR >> 1); - if (!ctx->i2c.tx_p1_client) + if (IS_ERR(ctx->i2c.tx_p1_client)) { + err = PTR_ERR(ctx->i2c.tx_p1_client); goto free_tx_p0; + } ctx->i2c.tx_p2_client = i2c_new_dummy_device(client->adapter, TX_P2_ADDR >> 1); - if (!ctx->i2c.tx_p2_client) + if (IS_ERR(ctx->i2c.tx_p2_client)) { + err = PTR_ERR(ctx->i2c.tx_p2_client); goto free_tx_p1; + } ctx->i2c.rx_p0_client = i2c_new_dummy_device(client->adapter, RX_P0_ADDR >> 1); - if (!ctx->i2c.rx_p0_client) + if (IS_ERR(ctx->i2c.rx_p0_client)) { + err = PTR_ERR(ctx->i2c.rx_p0_client); goto free_tx_p2; + } ctx->i2c.rx_p1_client = i2c_new_dummy_device(client->adapter, RX_P1_ADDR >> 1); - if (!ctx->i2c.rx_p1_client) + if (IS_ERR(ctx->i2c.rx_p1_client)) { + err = PTR_ERR(ctx->i2c.rx_p1_client); goto free_rx_p0; + } ctx->i2c.rx_p2_client = i2c_new_dummy_device(client->adapter, RX_P2_ADDR >> 1); - if (!ctx->i2c.rx_p2_client) + if (IS_ERR(ctx->i2c.rx_p2_client)) { + err = PTR_ERR(ctx->i2c.rx_p2_client); goto free_rx_p1; + } ctx->i2c.tcpc_client = i2c_new_dummy_device(client->adapter, TCPC_INTERFACE_ADDR >> 1); - if (!ctx->i2c.tcpc_client) + if (IS_ERR(ctx->i2c.tcpc_client)) { + err = PTR_ERR(ctx->i2c.tcpc_client); goto free_rx_p2; + } return 0; @@ -1687,7 +1701,7 @@ static int anx7625_register_i2c_dummy_clients(struct anx7625_data *ctx, free_tx_p0: i2c_unregister_device(ctx->i2c.tx_p0_client); - return -ENOMEM; + return err; } static void anx7625_unregister_i2c_dummy_clients(struct anx7625_data *ctx) -- 2.17.1
[PATCH] drm/i915/selftests: Fix NULL vs IS_ERR checking for kernel_context
Since i915_gem_create_context() function return error pointers, the kernel_context() function does not return null, It returns error pointers too. Using IS_ERR() to check the return value to fix this. Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/i915/gt/selftest_execlists.c | 41 ++-- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/selftest_execlists.c b/drivers/gpu/drm/i915/gt/selftest_execlists.c index b367ecfa42de..eacfe920afed 100644 --- a/drivers/gpu/drm/i915/gt/selftest_execlists.c +++ b/drivers/gpu/drm/i915/gt/selftest_execlists.c @@ -1540,13 +1540,16 @@ static int live_busywait_preempt(void *arg) */ ctx_hi = kernel_context(gt->i915, NULL); - if (!ctx_hi) - return -ENOMEM; + if (IS_ERR(ctx_hi)) + return IS_ERR(ctx_hi); + ctx_hi->sched.priority = I915_CONTEXT_MAX_USER_PRIORITY; ctx_lo = kernel_context(gt->i915, NULL); - if (!ctx_lo) + if (IS_ERR(ctx_lo)) { + err = PTR_ERR(ctx_lo); goto err_ctx_hi; + } ctx_lo->sched.priority = I915_CONTEXT_MIN_USER_PRIORITY; obj = i915_gem_object_create_internal(gt->i915, PAGE_SIZE); @@ -1742,13 +1745,17 @@ static int live_preempt(void *arg) goto err_spin_hi; ctx_hi = kernel_context(gt->i915, NULL); - if (!ctx_hi) + if (IS_ERR(ctx_hi)) { + err = PTR_ERR(ctx_hi); goto err_spin_lo; + } ctx_hi->sched.priority = I915_CONTEXT_MAX_USER_PRIORITY; ctx_lo = kernel_context(gt->i915, NULL); - if (!ctx_lo) + if (IS_ERR(ctx_lo)) { + err = PTR_ERR(ctx_lo); goto err_ctx_hi; + } ctx_lo->sched.priority = I915_CONTEXT_MIN_USER_PRIORITY; for_each_engine(engine, gt, id) { @@ -1834,12 +1841,16 @@ static int live_late_preempt(void *arg) goto err_spin_hi; ctx_hi = kernel_context(gt->i915, NULL); - if (!ctx_hi) + if (IS_ERR(ctx_hi)) { + err = PTR_ERR(ctx_hi); goto err_spin_lo; + } ctx_lo = kernel_context(gt->i915, NULL); - if (!ctx_lo) + if (IS_ERR(ctx_lo)) { + err = PTR_ERR(ctx_lo); goto err_ctx_hi; + } /* Make sure ctx_lo stays before ctx_hi until we trigger preemption. */ ctx_lo->sched.priority = 1; @@ -1928,8 +1939,8 @@ struct preempt_client { static int preempt_client_init(struct intel_gt *gt, struct preempt_client *c) { c->ctx = kernel_context(gt->i915, NULL); - if (!c->ctx) - return -ENOMEM; + if (IS_ERR(c->ctx)) + return PTR_ERR(c->ctx); if (igt_spinner_init(>spin, gt)) goto err_ctx; @@ -3385,13 +3396,17 @@ static int live_preempt_timeout(void *arg) return -ENOMEM; ctx_hi = kernel_context(gt->i915, NULL); - if (!ctx_hi) + if (IS_ERR(ctx_hi)) { + err = PTR_ERR(ctx_hi); goto err_spin_lo; + } ctx_hi->sched.priority = I915_CONTEXT_MAX_USER_PRIORITY; ctx_lo = kernel_context(gt->i915, NULL); - if (!ctx_lo) + if (IS_ERR(ctx_lo)) { + err = PTR_ERR(ctx_lo); goto err_ctx_hi; + } ctx_lo->sched.priority = I915_CONTEXT_MIN_USER_PRIORITY; for_each_engine(engine, gt, id) { @@ -3683,8 +3698,10 @@ static int live_preempt_smoke(void *arg) for (n = 0; n < smoke.ncontext; n++) { smoke.contexts[n] = kernel_context(smoke.gt->i915, NULL); - if (!smoke.contexts[n]) + if (IS_ERR(smoke.contexts[n])) { + err = PTR_ERR(smoke.contexts[n]); goto err_ctx; + } } for (n = 0; n < ARRAY_SIZE(phase); n++) { -- 2.17.1
[PATCH] drm/virtio: Fix NULL vs IS_ERR checking in virtio_gpu_object_shmem_init
Since drm_prime_pages_to_sg() function return error pointers. The drm_gem_shmem_get_sg_table() function returns error pointers too. Using IS_ERR() to check the return value to fix this. Fixes: f651c8b05542("drm/virtio: factor out the sg_table from virtio_gpu_object") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/virtio/virtgpu_object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c index f648b0e24447..8bb80289672c 100644 --- a/drivers/gpu/drm/virtio/virtgpu_object.c +++ b/drivers/gpu/drm/virtio/virtgpu_object.c @@ -168,9 +168,9 @@ static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev, * since virtio_gpu doesn't support dma-buf import from other devices. */ shmem->pages = drm_gem_shmem_get_sg_table(>base.base); - if (!shmem->pages) { + if (IS_ERR(shmem->pages)) { drm_gem_shmem_unpin(>base.base); - return -EINVAL; + return PTR_ERR(shmem->pages); } if (use_dma_api) { -- 2.17.1
[PATCH] drm/amdkfd: Fix missing check in kfd_parse_subtype_iolink
The kmemdup() function may return NULL in case of error. Add NULL checking to prevent potential null deference. Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c index cfedfb1e8596..59d55f752aa7 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c @@ -1060,6 +1060,8 @@ static int kfd_parse_subtype_iolink(struct crat_subtype_iolink *iolink, return -ENODEV; /* same everything but the other direction */ props2 = kmemdup(props, sizeof(*props2), GFP_KERNEL); + if (!props2) + return -ENOMEM; props2->node_from = id_to; props2->node_to = id_from; props2->kobj = NULL; -- 2.17.1
[PATCH] udmabuf: Fix NULL vs IS_ERR() checking
The get_sg_table() function does not return NULL. It returns error pointers. Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/arm/malidp_planes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c index 0562bdaac00c..2ef8feae8c4e 100644 --- a/drivers/gpu/drm/arm/malidp_planes.c +++ b/drivers/gpu/drm/arm/malidp_planes.c @@ -348,7 +348,7 @@ static bool malidp_check_pages_threshold(struct malidp_plane_state *ms, else sgt = obj->funcs->get_sg_table(obj); - if (!sgt) + if (IS_ERR(sgt)) return false; sgl = sgt->sgl; -- 2.17.1
[PATCH] lib/genalloc: Fix NULL vs IS_ERR() checking
The devm_gen_pool_create() function does not return NULL. It returns error pointers. Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/vboxvideo/vbox_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_main.c index f28779715ccd..c9e8b3a63c62 100644 --- a/drivers/gpu/drm/vboxvideo/vbox_main.c +++ b/drivers/gpu/drm/vboxvideo/vbox_main.c @@ -127,8 +127,8 @@ int vbox_hw_init(struct vbox_private *vbox) /* Create guest-heap mem-pool use 2^4 = 16 byte chunks */ vbox->guest_pool = devm_gen_pool_create(vbox->ddev.dev, 4, -1, "vboxvideo-accel"); - if (!vbox->guest_pool) - return -ENOMEM; + if (IS_ERR(vbox->guest_pool)) + return PTR_ERR(vbox->guest_pool); ret = gen_pool_add_virt(vbox->guest_pool, (unsigned long)vbox->guest_heap, -- 2.17.1
[PATCH] drm/i915/selftests: Fix inconsistent object in IS_ERR and PTR_ERR
Fix inconsistent object in IS_ERR and PTR_ERR in igt_dmabuf_import_same_driver and igt_dmabuf_import_same_driver_lmem. As obj is the return value of __i915_gem_object_create_user, the proper object to be passed as argument to PTR_ERR is obj. Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c index 4a6bb64c3a35..3cc74b0fed06 100644 --- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c +++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c @@ -102,7 +102,7 @@ static int igt_dmabuf_import_same_driver_lmem(void *arg) obj = __i915_gem_object_create_user(i915, PAGE_SIZE, , 1); if (IS_ERR(obj)) { pr_err("__i915_gem_object_create_user failed with err=%ld\n", - PTR_ERR(dmabuf)); + PTR_ERR(obj)); err = PTR_ERR(obj); goto out_ret; } @@ -158,7 +158,7 @@ static int igt_dmabuf_import_same_driver(struct drm_i915_private *i915, regions, num_regions); if (IS_ERR(obj)) { pr_err("__i915_gem_object_create_user failed with err=%ld\n", - PTR_ERR(dmabuf)); + PTR_ERR(obj)); err = PTR_ERR(obj); goto out_ret; } -- 2.17.1