Project

General

Profile

Actions

Feature #3270

open

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

Added by Ilya Shchepetkov over 11 years ago. Updated over 9 years ago.

Status:
Open
Priority:
Normal
Assignee:
-
Start date:
07/24/2012
Due date:
% Done:

0%

Estimated time:
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 1 (0 open1 closed)

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

Actions
Actions #1

Updated by Evgeny Novikov over 11 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.

Actions #2

Updated by Ilya Shchepetkov over 11 years ago

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

Actions #3

Updated by Ilya Shchepetkov over 11 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
Actions #4

Updated by Evgeny Novikov about 11 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).

Actions #5

Updated by Ilya Shchepetkov about 11 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.

Actions #6

Updated by Vadim Mutilin over 9 years ago

  • Description updated (diff)
Actions #7

Updated by Evgeny Novikov over 9 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.

Actions #8

Updated by Evgeny Novikov over 9 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.

Actions

Also available in: Atom PDF