* [PATCH][next] drm/omap: clean up error exit path on omap_encoder allocation failure
@ 2024-10-15 14:10 Colin Ian King
2024-10-28 8:28 ` Tomi Valkeinen
0 siblings, 1 reply; 2+ messages in thread
From: Colin Ian King @ 2024-10-15 14:10 UTC (permalink / raw)
To: Tomi Valkeinen, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, dri-devel
Cc: kernel-janitors, linux-kernel
Currently when an allocation failure occurs for omap_encoder the exit
path will destroy encoder via omap_encoder_destroy if it is not null.
However, encoder is always null at this point, so the check and destroy
is redundant and can be removed. Clean up the code by removing the exit
path and redundant omap_encoder_destroy call, and just return NULL.
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
drivers/gpu/drm/omapdrm/omap_encoder.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c b/drivers/gpu/drm/omapdrm/omap_encoder.c
index 4dd05bc732da..a99022638a2c 100644
--- a/drivers/gpu/drm/omapdrm/omap_encoder.c
+++ b/drivers/gpu/drm/omapdrm/omap_encoder.c
@@ -126,21 +126,15 @@ struct drm_encoder *omap_encoder_init(struct drm_device *dev,
omap_encoder = kzalloc(sizeof(*omap_encoder), GFP_KERNEL);
if (!omap_encoder)
- goto fail;
+ return NULL;
omap_encoder->output = output;
encoder = &omap_encoder->base;
drm_encoder_init(dev, encoder, &omap_encoder_funcs,
DRM_MODE_ENCODER_TMDS, NULL);
drm_encoder_helper_add(encoder, &omap_encoder_helper_funcs);
return encoder;
-
-fail:
- if (encoder)
- omap_encoder_destroy(encoder);
-
- return NULL;
}
--
2.39.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH][next] drm/omap: clean up error exit path on omap_encoder allocation failure
2024-10-15 14:10 [PATCH][next] drm/omap: clean up error exit path on omap_encoder allocation failure Colin Ian King
@ 2024-10-28 8:28 ` Tomi Valkeinen
0 siblings, 0 replies; 2+ messages in thread
From: Tomi Valkeinen @ 2024-10-28 8:28 UTC (permalink / raw)
To: Colin Ian King
Cc: kernel-janitors, linux-kernel, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, dri-devel
Hi,
On 15/10/2024 17:10, Colin Ian King wrote:
> Currently when an allocation failure occurs for omap_encoder the exit
> path will destroy encoder via omap_encoder_destroy if it is not null.
> However, encoder is always null at this point, so the check and destroy
> is redundant and can be removed. Clean up the code by removing the exit
> path and redundant omap_encoder_destroy call, and just return NULL.
>
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
> drivers/gpu/drm/omapdrm/omap_encoder.c | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
This is correct, but I think it would make sense to fix the error
handling in omap_encoder_init() fully, instead of just partially:
drm_encoder_init() can return an error, in which case we should free the
omap_encoder.
Could you update the patch to do that too?
Tomi
> diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c b/drivers/gpu/drm/omapdrm/omap_encoder.c
> index 4dd05bc732da..a99022638a2c 100644
> --- a/drivers/gpu/drm/omapdrm/omap_encoder.c
> +++ b/drivers/gpu/drm/omapdrm/omap_encoder.c
> @@ -126,21 +126,15 @@ struct drm_encoder *omap_encoder_init(struct drm_device *dev,
>
> omap_encoder = kzalloc(sizeof(*omap_encoder), GFP_KERNEL);
> if (!omap_encoder)
> - goto fail;
> + return NULL;
>
> omap_encoder->output = output;
>
> encoder = &omap_encoder->base;
>
> drm_encoder_init(dev, encoder, &omap_encoder_funcs,
> DRM_MODE_ENCODER_TMDS, NULL);
> drm_encoder_helper_add(encoder, &omap_encoder_helper_funcs);
>
> return encoder;
> -
> -fail:
> - if (encoder)
> - omap_encoder_destroy(encoder);
> -
> - return NULL;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-28 8:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-15 14:10 [PATCH][next] drm/omap: clean up error exit path on omap_encoder allocation failure Colin Ian King
2024-10-28 8:28 ` Tomi Valkeinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®