Fix some error handling paths in 'meson_drv_bind_master()'
Subsystems (5)
cover Fix some error handling paths in 'meson_drv_bind_master()'
Patch 1 and 3 are fixes.
Patch 2 is just a kind of clean-up noticed while patching this driver.
If patch 2 is considered as useless, patch 3 can be applied on top of patch 1, it does nor depend on the 2nd patch.
Christophe JAILLET (3):
drm/meson: Fix an un-handled error path in 'meson_drv_bind_master()' drm/meson: Use drm_dev_put() instead of drm_dev_unref() drm/meson: Fix some error handling paths in 'meson_drv_bind_master()'
drivers/gpu/drm/meson/meson_drv.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-)
Signature · 6 lines
2.14.1 --- L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast. https://www.avast.com/antivirus
PATCH 1/3 drm/meson: Fix an un-handled error path in 'meson_drv_bind_master()'
'drm_vblank_init()' can fail. So handle this (unlikely) error.
--- drivers/gpu/drm/meson/meson_drv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/meson/meson_drv.c +4 -1
@@ -222,7 +222,10 @@ static int meson_drv_bind_master(struct device *dev, bool has_components) priv->vsync_irq =platform_get_irq (pdev,0 ); -drm_vblank_init (drm,1 ); + ret =drm_vblank_init (drm,1 ); +if (ret) + goto free_drm; +drm_mode_config_init (drm); drm->mode_config.max_width =3840 ; drm->mode_config.max_height =2160 ;
Signature · 6 lines
2.14.1 --- L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast. https://www.avast.com/antivirus
Re: [PATCH 1/3] drm/meson: Fix an un-handled error path in 'meson_drv_bind_master()'
Quoted 15 lines · Christophe JAILLET
'
drm_vblank_init()' can fail. So handle this (unlikely) error.Fixes bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")Signed-off-by Christophe JAILLET <[email protected]>--- drivers/gpu/drm/meson/meson_drv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/meson/meson_drv.c +0
-0@@ -222,7 +222,10 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
drivers/gpu/drm/meson/meson_drv.c static int meson_drv_bind_master(struct device *dev, bool has_components) · line 231
Quoted 10 lines
drivers/gpu/drm/meson/meson_drv.c +4
-1priv->vsync_irq =platform_get_irq (pdev,0 ); -drm_vblank_init (drm,1 ); + ret =drm_vblank_init (drm,1 ); +if (ret) + goto free_drm; +drm_mode_config_init (drm); drm->mode_config.max_width =3840 ; drm->mode_config.max_height =2160 ;
Thanks,
Neil
PATCH 2/3 drm/meson: Use drm_dev_put() instead of drm_dev_unref()
In reply to Christophe JAILLETAccording to 'drivers/gpu/drm/drm_drv.c', 'drm_dev_unref()' is just a compatibility alias for 'drm_dev_put()'. So use the latter instead.
--- drivers/gpu/drm/meson/meson_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/meson/meson_drv.c +2 -2
@@ -284,7 +284,7 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)return 0 ; free_drm: -drm_dev_unref (drm); +drm_dev_put (drm);return ret; }
@@ -303,7 +303,7 @@ static void meson_drv_unbind(struct device *dev)drm_kms_helper_poll_fini (drm);drm_fbdev_cma_fini (priv->fbdev);drm_mode_config_cleanup (drm); -drm_dev_unref (drm); +drm_dev_put (drm); }
Signature · 6 lines
2.14.1 --- L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast. https://www.avast.com/antivirus
Re: [PATCH 2/3] drm/meson: Use drm_dev_put() instead of drm_dev_unref()
Quoted 23 lines · Christophe JAILLET
According to '
drivers/gpu/drm/drm_drv.c', 'drm_dev_unref()' is just a compatibility alias for 'drm_dev_put()'. So use the latter instead.Signed-off-by Christophe JAILLET <[email protected]>--- drivers/gpu/drm/meson/meson_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/meson/meson_drv.c +1
-1@@ -284,7 +284,7 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)return 0 ; free_drm: -drm_dev_unref (drm); +drm_dev_put (drm);return ret; }
drivers/gpu/drm/meson/meson_drv.c static void meson_drv_unbind(struct device *dev) · line 309
Quoted 8 lines
drivers/gpu/drm/meson/meson_drv.c +1
-1@@ -303,7 +303,7 @@ static void meson_drv_unbind(struct device *dev)drm_kms_helper_poll_fini (drm);drm_fbdev_cma_fini (priv->fbdev);drm_mode_config_cleanup (drm); -drm_dev_unref (drm); +drm_dev_put (drm); }
It's not useless, there is a clear statement :
* This is a compatibility alias for drm_dev_put() and should not be used by new
* code.
Thanks,
Neil
PATCH 3/3 drm/meson: Fix some error handling paths in 'meson_drv_bind_master()'
In reply to Christophe JAILLETIf one of these functions fail, we whould free 'drm', as alreadry done in the other error handling paths, below and above.
--- drivers/gpu/drm/meson/meson_drv.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
drivers/gpu/drm/meson/meson_drv.c +16 -8
@@ -189,35 +189,43 @@ static int meson_drv_bind_master(struct device *dev, bool has_components) res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"vpu" ); regs =devm_ioremap_resource (dev, res); -if (IS_ERR (regs)) -return PTR_ERR (regs); +if (IS_ERR (regs)) { + ret =PTR_ERR (regs); + goto free_drm; + } priv->io_base = regs; res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"hhi" );/* Simply ioremap since it may be a shared register zone */ regs =devm_ioremap (dev, res->start,resource_size (res)); -if (!regs) -return -EADDRNOTAVAIL ; +if (!regs) { + ret = -EADDRNOTAVAIL ; + goto free_drm; + } priv->hhi =devm_regmap_init_mmio (dev, regs, &meson_regmap_config);if (IS_ERR (priv->hhi)) {dev_err (&pdev->dev,"Couldn't create the HHI regmap\n" ); -return PTR_ERR (priv->hhi); + ret =PTR_ERR (priv->hhi); + goto free_drm; } res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"dmc" );/* Simply ioremap since it may be a shared register zone */ regs =devm_ioremap (dev, res->start,resource_size (res)); -if (!regs) -return -EADDRNOTAVAIL ; +if (!regs) { + ret = -EADDRNOTAVAIL ; + goto free_drm; + } priv->dmc =devm_regmap_init_mmio (dev, regs, &meson_regmap_config);if (IS_ERR (priv->dmc)) {dev_err (&pdev->dev,"Couldn't create the DMC regmap\n" ); -return PTR_ERR (priv->dmc); + ret =PTR_ERR (priv->dmc); + goto free_drm; } priv->vsync_irq =platform_get_irq (pdev,0 );
Signature · 6 lines
2.14.1 --- L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast. https://www.avast.com/antivirus
Re: [PATCH 3/3] drm/meson: Fix some error handling paths in 'meson_drv_bind_master()'
Quoted 56 lines · Christophe JAILLET
If one of these functions fail, we whould free 'drm', as alreadry done in the other error handling paths, below and above.
Fixes bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")Signed-off-by Christophe JAILLET <[email protected]>--- drivers/gpu/drm/meson/meson_drv.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)drivers/gpu/drm/meson/meson_drv.c +14
-7@@ -189,35 +189,43 @@ static int meson_drv_bind_master(struct device *dev, bool has_components) res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"vpu" ); regs =devm_ioremap_resource (dev, res); -if (IS_ERR (regs)) -return PTR_ERR (regs); +if (IS_ERR (regs)) { + ret =PTR_ERR (regs); + goto free_drm; + } priv->io_base = regs; res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"hhi" );/* Simply ioremap since it may be a shared register zone */ regs =devm_ioremap (dev, res->start,resource_size (res)); -if (!regs) -return -EADDRNOTAVAIL ; +if (!regs) { + ret = -EADDRNOTAVAIL ; + goto free_drm; + } priv->hhi =devm_regmap_init_mmio (dev, regs, &meson_regmap_config);if (IS_ERR (priv->hhi)) {dev_err (&pdev->dev,"Couldn't create the HHI regmap\n" ); -return PTR_ERR (priv->hhi); + ret =PTR_ERR (priv->hhi); + goto free_drm; } res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"dmc" );/* Simply ioremap since it may be a shared register zone */ regs =devm_ioremap (dev, res->start,resource_size (res)); -if (!regs) -return -EADDRNOTAVAIL ; +if (!regs) { + ret = -EADDRNOTAVAIL ; + goto free_drm; + }
drivers/gpu/drm/meson/meson_drv.c static int meson_drv_bind_master(struct device *dev, bool has_components) · line 231
Quoted 10 lines
drivers/gpu/drm/meson/meson_drv.c +2
-1priv->dmc =devm_regmap_init_mmio (dev, regs, &meson_regmap_config);if (IS_ERR (priv->dmc)) {dev_err (&pdev->dev,"Couldn't create the DMC regmap\n" ); -return PTR_ERR (priv->dmc); + ret =PTR_ERR (priv->dmc); + goto free_drm; } priv->vsync_irq =platform_get_irq (pdev,0 );
Thanks,
Neil
Quoted 6 lines · Christophe JAILLET
Patch 1 and 3 are fixes.
Patch 2 is just a kind of clean-up noticed while patching this driver.If patch 2 is considered as useless, patch 3 can be applied on top of patch 1, it does nor depend on the 2nd patch.
Quoted 8 lines
Christophe JAILLET (3):
drm/meson: Fix an un-handled error path in 'meson_drv_bind_master()' drm/meson: Usedrm_dev_put()instead ofdrm_dev_unref()drm/meson: Fix some error handling paths in 'meson_drv_bind_master()'drivers/gpu/drm/meson/meson_drv.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-)
Hi,
Thanks for the fixes, since they are not critical, I pushed them on drm-misc-next, they will be backported onto stable tree by the stable team later on using the Fixes tag.
Neil