Commit 6766f59
Bartosz Golaszewski
gpio: sysfs: fix chip removal with GPIOs exported over sysfs
Currently if we export a GPIO over sysfs and unbind the parent GPIO
controller, the exported attribute will remain under /sys/class/gpio
because once we remove the parent device, we can no longer associate the
descriptor with it in gpiod_unexport() and never drop the final
reference.
Rework the teardown code: provide an unlocked variant of
gpiod_unexport() and remove all exported GPIOs with the sysfs_lock taken
before unregistering the parent device itself. This is done to prevent
any new exports happening before we unregister the device completely.
Cc: stable@vger.kernel.org
Fixes: 1cd53df ("gpio: sysfs: don't look up exported lines as class devices")
Link: https://patch.msgid.link/20260212133505.81516-1-bartosz.golaszewski@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>1 parent ff91965 commit 6766f59
1 file changed
Lines changed: 55 additions & 51 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
919 | 919 | | |
920 | 920 | | |
921 | 921 | | |
922 | | - | |
923 | | - | |
924 | | - | |
925 | | - | |
926 | | - | |
927 | | - | |
928 | | - | |
| 922 | + | |
929 | 923 | | |
930 | 924 | | |
931 | 925 | | |
932 | 926 | | |
933 | 927 | | |
934 | | - | |
935 | | - | |
| 928 | + | |
936 | 929 | | |
937 | | - | |
938 | 930 | | |
939 | | - | |
940 | | - | |
941 | | - | |
942 | | - | |
943 | | - | |
944 | | - | |
945 | | - | |
946 | | - | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
947 | 935 | | |
948 | | - | |
949 | | - | |
950 | | - | |
951 | | - | |
952 | | - | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
953 | 940 | | |
| 941 | + | |
954 | 942 | | |
955 | | - | |
956 | | - | |
| 943 | + | |
| 944 | + | |
957 | 945 | | |
958 | | - | |
959 | | - | |
| 946 | + | |
| 947 | + | |
960 | 948 | | |
961 | | - | |
962 | | - | |
963 | | - | |
964 | | - | |
965 | | - | |
966 | | - | |
967 | | - | |
968 | | - | |
969 | | - | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
970 | 958 | | |
971 | 959 | | |
972 | | - | |
973 | | - | |
974 | | - | |
| 960 | + | |
| 961 | + | |
975 | 962 | | |
976 | 963 | | |
977 | 964 | | |
978 | 965 | | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
979 | 984 | | |
980 | 985 | | |
981 | 986 | | |
| |||
1054 | 1059 | | |
1055 | 1060 | | |
1056 | 1061 | | |
1057 | | - | |
1058 | | - | |
1059 | | - | |
1060 | | - | |
| 1062 | + | |
1061 | 1063 | | |
1062 | | - | |
1063 | | - | |
1064 | | - | |
1065 | | - | |
1066 | | - | |
1067 | | - | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
1068 | 1067 | | |
1069 | 1068 | | |
1070 | | - | |
1071 | 1069 | | |
1072 | 1070 | | |
1073 | 1071 | | |
1074 | 1072 | | |
1075 | 1073 | | |
1076 | 1074 | | |
1077 | | - | |
| 1075 | + | |
1078 | 1076 | | |
1079 | 1077 | | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
1080 | 1084 | | |
1081 | 1085 | | |
1082 | 1086 | | |
| |||
0 commit comments