Re: [cocci] [PATCH] cocci: drm: report devm-allocated arguments and fields
From: Markus Elfring
Date: Wed Sep 24 2025 - 11:11:47 EST
> Add two Coccinelle rules: (1) flag a devres-managed pointer
> passed to a drm-init function, and (2) flag a devres-managed
> pointer assigned to a field of drm-managed struct. …
I suggest to start each enumeration item on a separate text line.
Would you like to refer to “Coccinelle: api:” in the patch prefix?
…> +// Copyright: (C) 2025 Oleg Petrov ISPRAS
Would another delimiter be helpful between the personal name and the organisation identifier?
…> +virtual report
> +virtual org
The restriction on the support for two operation modes will need further development considerations.
…> +devm = \(devm_kzalloc\|devm_kcalloc\|devm_kmalloc\|devm_kmalloc_array\)(...);
Would it be nicer to write such SmPL disjunctions on multiple lines?
…> +@script:python depends on report@
> +p << badarg.p;
> +@@
> +msg = "WARNING devm-allocated argument in a drm-init; use drmm-init family (or drmm-alloc)."
> +coccilib.report.print_report(p[0], msg)
I would like to point out once more that such data can be printed
also without an extra variable like “msg”.
> +@script:python depends on org@
> +p << badarg.p;
> +@@
> +msg = "WARNING devm-allocated argument in a drm-init; use drmm-init family (or drmm-alloc)."
> +coccilib.org.print_report(p[0], msg)
Would the following method call be more appropriate?
coccilib.org.print_todo(p[0],
"WARNING: devm-allocated argument in a drm-init; use drmm-init family (or drmm-alloc).")
Regards,
Markus