mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Michel Dänzer" <michel.daenzer@mailbox.org>
To: Markus Elfring <Markus.Elfring@web.de>,
	dri-devel@lists.freedesktop.org, kernel-janitors@vger.kernel.org,
	Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@gmail.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>
Cc: LKML <linux-kernel@vger.kernel.org>, cocci@inria.fr
Subject: Re: [PATCH 1/3] drm: property: One function call less in drm_property_create() after error detection
Date: Wed, 3 Jan 2024 16:16:38 +0100	[thread overview]
Message-ID: <37647c33-7f9d-4763-8bf4-cfc5c9a811de@mailbox.org> (raw)
In-Reply-To: <9b1e7330-f4f6-47f8-a568-eaea1624bb6f@web.de>

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


  reply	other threads:[~2024-01-03 15:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-26  9:36 [PATCH 0/3] drm: property: Adjustments for three function implementations Markus Elfring
2023-12-26  9:38 ` [PATCH 1/3] drm: property: One function call less in drm_property_create() after error detection Markus Elfring
2024-01-03 15:16   ` Michel Dänzer [this message]
2024-01-03 16:24     ` Markus Elfring
2024-01-03 17:18       ` Michel Dänzer
2024-01-03 18:08         ` [1/3] " Markus Elfring
2024-01-04  9:26           ` Michel Dänzer
2024-01-04 12:21             ` Markus Elfring
2024-01-04 15:26         ` [PATCH 1/3] " Dan Carpenter
2023-12-26  9:40 ` [PATCH 2/3] drm: property: Delete an unnecessary initialisation in drm_property_create() Markus Elfring
2023-12-26  9:42 ` [PATCH 3/3] drm: property: Improve four size determinations Markus Elfring
2023-12-26 10:10   ` Simon Ser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=37647c33-7f9d-4763-8bf4-cfc5c9a811de@mailbox.org \
    --to=michel.daenzer@mailbox.org \
    --cc=Markus.Elfring@web.de \
    --cc=airlied@gmail.com \
    --cc=cocci@inria.fr \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®