Feature #3270

130: Initialize dynamically allocated sysfs attributes before device_create_file() call

Added by Ilya Shchepetkov about 5 years ago. Updated almost 3 years ago.

Status:OpenStart date:07/24/2012
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-
Published in build:

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


Related issues

Related to C Instrumentation Framework - Feature #3890: Deal with Linux kernel API macros at global scope Closed 01/29/2013

History

#1 Updated by Evgeny Novikov about 5 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.

#2 Updated by Ilya Shchepetkov about 5 years ago

There will be a large number of false positives, I think, but I'll try.

#3 Updated by Ilya Shchepetkov about 5 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

#4 Updated by Evgeny Novikov over 4 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).

#5 Updated by Ilya Shchepetkov over 4 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.

#6 Updated by Vadim Mutilin almost 3 years ago

  • Description updated (diff)

#7 Updated by Evgeny Novikov almost 3 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.

#8 Updated by Evgeny Novikov almost 3 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.

Also available in: Atom PDF