Commit ab3428c
nvmem: core: fix registration vs use race
The i.MX6 CPU frequency driver sometimes fails to register at boot time
due to nvmem_cell_read_u32() sporadically returning -ENOENT.
This happens because there is a window where __nvmem_device_get() in
of_nvmem_cell_get() is able to return the nvmem device, but as cells
have been setup, nvmem_find_cell_entry_by_node() returns NULL.
The occurs because the nvmem core registration code violates one of the
fundamental principles of kernel programming: do not publish data
structures before their setup is complete.
Fix this by making nvmem core code conform with this principle.
Fixes: eace75c ("nvmem: Add a simple NVMEM framework for nvmem providers")
Cc: [email protected]
Signed-off-by: Russell King (Oracle) <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>1 parent 560181d commit ab3428c
1 file changed
+8
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
832 | 832 | | |
833 | 833 | | |
834 | 834 | | |
835 | | - | |
836 | | - | |
837 | | - | |
838 | | - | |
839 | | - | |
840 | | - | |
841 | 835 | | |
842 | 836 | | |
843 | 837 | | |
844 | | - | |
| 838 | + | |
845 | 839 | | |
846 | 840 | | |
847 | 841 | | |
848 | 842 | | |
849 | 843 | | |
850 | | - | |
| 844 | + | |
851 | 845 | | |
852 | 846 | | |
853 | 847 | | |
| |||
864 | 858 | | |
865 | 859 | | |
866 | 860 | | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
867 | 867 | | |
868 | 868 | | |
869 | 869 | | |
| |||
873 | 873 | | |
874 | 874 | | |
875 | 875 | | |
876 | | - | |
877 | | - | |
878 | 876 | | |
879 | 877 | | |
880 | 878 | | |
| |||
0 commit comments