Feature #3270
open130: Initialize dynamically allocated sysfs attributes before device_create_file() call
0%
Description
Initialize dynamically allocated sysfs attributes before device_create_file() call to suppress lockdep_init_map() warning if lockdep debugging is enabled (Ńorresponding call sysfs_attr_init should be before the call device_create_file).
Device attributes can be allocated statically and dynamically. Static allocation of attribute is done via a macro DEVICE_ATTR (instead can be used similar macro, written by the authors of specific driver). Thus, if the attribute is allocated using a macro, there is no need to call a function sysfs_attr_init.
Example:
ibmaem.c
Links
Sample bugfixes f40e1a4, 4ee267b, af3071a, d631323
See also:
device.txt
sysfs.txt
Updated by Evgeny Novikov over 12 years ago
- Status changed from Open to New
- Assignee set to Ilya Shchepetkov
I guess that good model for this rule requires features of static verifiers that aren't supported. But we can try a cheat: let's count the number of macro DEVICE_ATTR (or similar ones), function sysfs_attr_init and device_create_file invocations. If all is ok, then at the end a sum of the first and the second numbers should be equal to the third number. It isn't ideal, but will allow to find some bugs.
What do you think about this? If you find this appropriate then implement corresponding model and test it.
Updated by Ilya Shchepetkov over 12 years ago
There will be a large number of false positives, I think, but I'll try.
Updated by Ilya Shchepetkov over 12 years ago
- Subject changed from 114: Initialize dynamically allocated sysfs attributes before device_create_file() call to 130: Initialize dynamically allocated sysfs attributes before device_create_file() call
Updated by Evgeny Novikov almost 12 years ago
- Status changed from New to Open
Please, use ability to process actual arguments of macrofunctions substituted at the global scope like in 148_7a model (implemented in #3890).
Updated by Ilya Shchepetkov almost 12 years ago
- Status changed from Open to Resolved
The ability to process actual arguments of macrofunctions substituted at the global scope was added in the commit 245cd35 of master branch.
Updated by Evgeny Novikov about 10 years ago
- Status changed from Resolved to Open
- Assignee deleted (
Ilya Shchepetkov)
I have fixed it in branch fix-130_7a so that we gained some more points in validating LDV. But we still need to run the rule specification on the whole kernel and possibly to fix it.
Updated by Evgeny Novikov about 10 years ago
Test "ldv-tests/rule-models/drivers/130_7a/test-S-DEVICE_ATTR/test-S-DEVICE_ATTR.c" was broken a bit to overcome absence of the device_remove_file() model.