130: Initialize dynamically allocated sysfs attributes before device_create_file() call
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.
Updated by Evgeny Novikov over 7 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 Evgeny Novikov over 5 years ago
- Status changed from Resolved to Open
- Assignee deleted (
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.