在 2022/9/21 3:21, Markus Elfring 写道:
Find mutex inside struct which is possibly used without init,
provide the name of the struct and of the mutex, the position
where the struct is malloced and where the mutex get locked.
I find this commit message variant also improvable.
Will terms like “data structure” and “initialisation” become relevant?
I would appreciate answers to my previous questions.
https://lore.kernel.org/cocci/fb101290-3ec7-9170-9fec-43e1b5f54c52@xxxxxx/
https://sympa.inria.fr/sympa/arc/cocci/2022-09/msg00022.html
I would expect a cover letter for patch series.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.0-rc6#n321
Thanks for the advice, I will send with cover letter in the next version.
…
+++ b/scripts/coccinelle/locks/missing_mutex_init.cocci
…
+// Comments:
Why do you suggest the addition of an empty comment field?
+mutex_init(\(&mm->fld\|&(mm->fld)\))
An extra SmPL disjunction is probably unnecessary because of an isomorphism.
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/3f7496ff9c2c5d4fadae1e585aa458e1a0037972/standard.iso#L382
https://github.com/coccinelle/coccinelle/blob/19ee1697bf152d37a78a20cefe148775bf4b0e0d/standard.iso#L382
+mutex_init(&(mm->fld))
Thanks for pointing out this, I will remove the former one in the next
version.
…
+@r3@
+identifier s, fld;
+position p != {r2.p};
Why do you think that such a SmPL constraint would be required?
+@@
+
+struct s {
+ ...
+ struct mutex fld@p;
+ ...
+};
Why would the source code search repetition matter here?
…
+@r5 depends on r4@
+identifier r3.s;
+struct s *mm;
+position p;
+@@
+* mm@p = \(kmalloc\|kzalloc\|devm_kmalloc\|devm_kzalloc\)(...)
I would expect that the usage of the asterisk in the first column should belong
to the operation mode “context”.
Will it become relevant to detect any more memory allocation function calls?
I do not mean to support context mode, I will remove it in the next version.
Thanks for you review!
Best regards,
Yuan Can