From: Markus Elfring <Markus.Elfring@web.de>
To: "Michel Dänzer" <michel.daenzer@mailbox.org>,
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 17:24:53 +0100 [thread overview]
Message-ID: <c5f1a7bf-b444-4934-a205-3c2b3a045ff7@web.de> (raw)
In-Reply-To: <37647c33-7f9d-4763-8bf4-cfc5c9a811de@mailbox.org>
>> 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.
…
>> +++ 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;
>> }
…
> This change is pointless at best, kfree(NULL) works fine.
* Would you interpret such a special function call as redundant?
* Do you find advices applicable from another information source
also for this function implementation?
https://wiki.sei.cmu.edu/confluence/display/c/MEM12-C.+Consider+using+a+goto+chain+when+leaving+a+function+on+error+when+using+and+releasing+resources
> Out of curiosity, what exactly did Coccinelle report?
Some SmPL scripts from my own selection tend to point questionable implementation details out.
Regards,
Markus
next prev parent reply other threads:[~2024-01-03 16:25 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
2024-01-03 16:24 ` Markus Elfring [this message]
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=c5f1a7bf-b444-4934-a205-3c2b3a045ff7@web.de \
--to=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=michel.daenzer@mailbox.org \
--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®