[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <37647c33-7f9d-4763-8bf4-cfc5c9a811de@mailbox.org>
Date: Wed, 3 Jan 2024 16:16:38 +0100
From: Michel Dänzer <michel.daenzer@...lbox.org>
To: Markus Elfring <Markus.Elfring@....de>, dri-devel@...ts.freedesktop.org,
kernel-janitors@...r.kernel.org, Daniel Vetter <daniel@...ll.ch>,
David Airlie <airlied@...il.com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>
Cc: LKML <linux-kernel@...r.kernel.org>, cocci@...ia.fr
Subject: Re: [PATCH 1/3] drm: property: One function call less in
drm_property_create() after error detection
On 2023-12-26 10:38, Markus Elfring wrote:
> From: Markus Elfring <elfring@...rs.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@...rs.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
Powered by blists - more mailing lists