lkml.org 
[lkml]   [2024]   [Jan]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 1/3] drm: property: One function call less in drm_property_create() after error detection
From
On 2023-12-26 10:38, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 26 Dec 2023 08:44:37 +0100
>
> The kfree() function was called in one case by the
> drm_property_create() function during error handling
> even if the passed data structure member contained a null pointer.
> This issue was detected by using the Coccinelle software.
>
> Thus use another label.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/gpu/drm/drm_property.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c
> index 596272149a35..3440f4560e6e 100644
> --- a/drivers/gpu/drm/drm_property.c
> +++ b/drivers/gpu/drm/drm_property.c
> @@ -117,7 +117,7 @@ struct drm_property *drm_property_create(struct drm_device *dev,
> property->values = kcalloc(num_values, sizeof(uint64_t),
> GFP_KERNEL);
> if (!property->values)
> - goto fail;
> + goto free_property;
> }
>
> ret = drm_mode_object_add(dev, &property->base, DRM_MODE_OBJECT_PROPERTY);
> @@ -135,6 +135,7 @@ struct drm_property *drm_property_create(struct drm_device *dev,
> return property;
> fail:
> kfree(property->values);
> +free_property:
> kfree(property);
> return NULL;
> }
> --
> 2.43.0
>

This change is pointless at best, kfree(NULL) works fine.


Out of curiosity, what exactly did Coccinelle report?


--
Earthling Michel Dänzer | https://redhat.com
Libre software enthusiast | Mesa and Xwayland developer


\
 
 \ /
  Last update: 2024-01-03 16:18    [W:0.050 / U:1.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site