Commit 7f1a57f
power_supply: Fix possible NULL pointer dereference on early uevent
Don't call the power_supply_changed() from power_supply_register() when
parent is still probing because it may lead to accessing parent too
early.
In bq27x00_battery this caused NULL pointer exception because uevent of
power_supply_changed called back the the get_property() method provided
by the driver. The get_property() method accessed pointer which should
be returned by power_supply_register().
Starting from bq27x00_battery_probe():
di->bat = power_supply_register()
power_supply_changed()
kobject_uevent()
power_supply_uevent()
power_supply_show_property()
power_supply_get_property()
bq27x00_battery_get_property()
dereference of di->bat which is NULL here
The dereference of di->bat (value returned by power_supply_register())
is the currently visible problem. However calling back the methods
provided by driver before ending the probe may lead to accessing other
driver-related data which is not yet initialized.
The call to power_supply_changed() is postponed till probing ends -
mutex of parent device is released.
Reported-by: H. Nikolaus Schaller <[email protected]>
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Fixes: 297d716 ("power_supply: Change ownership from driver to core")
Tested-By: Dr. H. Nikolaus Schaller <[email protected]>
Signed-off-by: Sebastian Reichel <[email protected]>1 parent 8e59c7f commit 7f1a57f
File tree
2 files changed
+46
-5
lines changed- drivers/power
- include/linux
2 files changed
+46
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
124 | 150 | | |
125 | 151 | | |
126 | 152 | | |
| |||
645 | 671 | | |
646 | 672 | | |
647 | 673 | | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
648 | 678 | | |
649 | 679 | | |
650 | 680 | | |
| |||
671 | 701 | | |
672 | 702 | | |
673 | 703 | | |
| 704 | + | |
| 705 | + | |
674 | 706 | | |
675 | 707 | | |
676 | 708 | | |
| |||
709 | 741 | | |
710 | 742 | | |
711 | 743 | | |
712 | | - | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
713 | 748 | | |
714 | 749 | | |
715 | 750 | | |
| |||
729 | 764 | | |
730 | 765 | | |
731 | 766 | | |
732 | | - | |
| 767 | + | |
| 768 | + | |
733 | 769 | | |
734 | 770 | | |
735 | 771 | | |
| |||
750 | 786 | | |
751 | 787 | | |
752 | 788 | | |
753 | | - | |
| 789 | + | |
| 790 | + | |
754 | 791 | | |
755 | 792 | | |
756 | 793 | | |
| |||
779 | 816 | | |
780 | 817 | | |
781 | 818 | | |
782 | | - | |
| 819 | + | |
| 820 | + | |
783 | 821 | | |
784 | 822 | | |
785 | 823 | | |
| |||
814 | 852 | | |
815 | 853 | | |
816 | 854 | | |
817 | | - | |
| 855 | + | |
| 856 | + | |
818 | 857 | | |
819 | 858 | | |
820 | 859 | | |
| |||
858 | 897 | | |
859 | 898 | | |
860 | 899 | | |
| 900 | + | |
861 | 901 | | |
862 | 902 | | |
863 | 903 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
240 | 241 | | |
241 | 242 | | |
242 | 243 | | |
| |||
0 commit comments