Re: [1/3] drm: property: One function call less in drm_property_create() after error detection

From: Markus Elfring
Date: Thu Jan 04 2024 - 07:23:10 EST


> The commit log says:
>
> This issue was detected by using the Coccinelle software.
>
> Either that's inaccurate then,

No.


> or you should be able to provide the corresponding output from Coccinelle.

Do you find data (like the following) more helpful for the adjustment
of affected implementation details?


Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> LANG=C git status && spatch …/Projekte/Coccinelle/janitor/show_jumps_to_kfree_with_null_pointer.cocci drivers/gpu/drm/drm_property.c
HEAD detached at next-20240104

@@ -114,9 +114,6 @@ struct drm_property *drm_property_create
property->dev = dev;

if (num_values) {
- property->values = kcalloc(num_values, sizeof(uint64_t),
- GFP_KERNEL);
- if (!property->values)
goto fail;
}

@@ -133,8 +130,6 @@ struct drm_property *drm_property_create
list_add_tail(&property->head, &dev->mode_config.property_list);

return property;
-fail:
- kfree(property->values);
kfree(property);
return NULL;
}


How do you think about to extend the application of script variants
for the semantic patch language?

Regards,
Markus