2023-11-29 11:35:04

by Haoran Liu

[permalink] [raw]
Subject: [PATCH v2] [drm/meson] meson_plane: Add error handling v2(re-aligned)

This patch adds robust error handling to the meson_plane_create
function in drivers/gpu/drm/meson/meson_plane.c. The function
previously lacked proper handling for potential failure scenarios
of the drm_universal_plane_init call.

Signed-off-by: Haoran Liu <[email protected]>
---
drivers/gpu/drm/meson/meson_plane.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/meson/meson_plane.c b/drivers/gpu/drm/meson/meson_plane.c
index 815dfe30492b..b43ac61201f3 100644
--- a/drivers/gpu/drm/meson/meson_plane.c
+++ b/drivers/gpu/drm/meson/meson_plane.c
@@ -534,6 +534,7 @@ int meson_plane_create(struct meson_drm *priv)
struct meson_plane *meson_plane;
struct drm_plane *plane;
const uint64_t *format_modifiers = format_modifiers_default;
+ int ret;

meson_plane = devm_kzalloc(priv->drm->dev, sizeof(*meson_plane),
GFP_KERNEL);
@@ -548,12 +549,16 @@ int meson_plane_create(struct meson_drm *priv)
else if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A))
format_modifiers = format_modifiers_afbc_g12a;

- drm_universal_plane_init(priv->drm, plane, 0xFF,
- &meson_plane_funcs,
- supported_drm_formats,
- ARRAY_SIZE(supported_drm_formats),
- format_modifiers,
- DRM_PLANE_TYPE_PRIMARY, "meson_primary_plane");
+ ret = drm_universal_plane_init(priv->drm, plane, 0xFF,
+ &meson_plane_funcs,
+ supported_drm_formats,
+ ARRAY_SIZE(supported_drm_formats),
+ format_modifiers,
+ DRM_PLANE_TYPE_PRIMARY, "meson_primary_plane");
+ if (ret) {
+ devm_kfree(priv->drm->dev, meson_plane);
+ return ret;
+ }

drm_plane_helper_add(plane, &meson_plane_helper_funcs);

--
2.17.1


2024-06-06 08:26:08

by Neil Armstrong

[permalink] [raw]
Subject: Re: [PATCH v2] [drm/meson] meson_plane: Add error handling v2(re-aligned)

On 29/11/2023 12:34, Haoran Liu wrote:
> This patch adds robust error handling to the meson_plane_create
> function in drivers/gpu/drm/meson/meson_plane.c. The function
> previously lacked proper handling for potential failure scenarios
> of the drm_universal_plane_init call.
>
> Signed-off-by: Haoran Liu <[email protected]>
> ---
> drivers/gpu/drm/meson/meson_plane.c | 17 +++++++++++------
> 1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/meson/meson_plane.c b/drivers/gpu/drm/meson/meson_plane.c
> index 815dfe30492b..b43ac61201f3 100644
> --- a/drivers/gpu/drm/meson/meson_plane.c
> +++ b/drivers/gpu/drm/meson/meson_plane.c
> @@ -534,6 +534,7 @@ int meson_plane_create(struct meson_drm *priv)
> struct meson_plane *meson_plane;
> struct drm_plane *plane;
> const uint64_t *format_modifiers = format_modifiers_default;
> + int ret;
>
> meson_plane = devm_kzalloc(priv->drm->dev, sizeof(*meson_plane),
> GFP_KERNEL);
> @@ -548,12 +549,16 @@ int meson_plane_create(struct meson_drm *priv)
> else if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A))
> format_modifiers = format_modifiers_afbc_g12a;
>
> - drm_universal_plane_init(priv->drm, plane, 0xFF,
> - &meson_plane_funcs,
> - supported_drm_formats,
> - ARRAY_SIZE(supported_drm_formats),
> - format_modifiers,
> - DRM_PLANE_TYPE_PRIMARY, "meson_primary_plane");
> + ret = drm_universal_plane_init(priv->drm, plane, 0xFF,
> + &meson_plane_funcs,
> + supported_drm_formats,
> + ARRAY_SIZE(supported_drm_formats),
> + format_modifiers,
> + DRM_PLANE_TYPE_PRIMARY, "meson_primary_plane");
> + if (ret) {
> + devm_kfree(priv->drm->dev, meson_plane);
> + return ret;
> + }
>
> drm_plane_helper_add(plane, &meson_plane_helper_funcs);
>

Reviewed-by: Neil Armstrong <[email protected]>

2024-06-06 09:25:58

by Neil Armstrong

[permalink] [raw]
Subject: Re: [PATCH v2] [drm/meson] meson_plane: Add error handling v2(re-aligned)

Hi,

On Wed, 29 Nov 2023 03:34:05 -0800, Haoran Liu wrote:
> This patch adds robust error handling to the meson_plane_create
> function in drivers/gpu/drm/meson/meson_plane.c. The function
> previously lacked proper handling for potential failure scenarios
> of the drm_universal_plane_init call.
>
>

Thanks, Applied to https://gitlab.freedesktop.org/drm/misc/kernel.git (drm-misc-next)

[1/1] meson_plane: Add error handling v2(re-aligned)
https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/3c28b239620e249b68beeca17f429e317fa6b8d4

--
Neil