aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Deacon2020-12-15 11:15:38 -0600
committerGiuliano Procida2020-12-30 04:20:48 -0600
commit03f232dcf8d411cd1b7fa6207018b706dbaf8229 (patch)
treeec27a6f57b96ea590ccf5d0eadee19d03631abce
parentdafa07c7e5a5e34f2908dc4a2e4feee709beabc9 (diff)
downloadkernel-03f232dcf8d411cd1b7fa6207018b706dbaf8229.tar.gz
kernel-03f232dcf8d411cd1b7fa6207018b706dbaf8229.tar.xz
kernel-03f232dcf8d411cd1b7fa6207018b706dbaf8229.zip
ANDROID: usb: f_accessory: Avoid bitfields for shared variables
Using bitfields for shared variables is a "bad idea", as they require a non-atomic read-modify-write to be generated by the compiler, which can cause updates to unrelated bits in the same word to disappear. Ensure the 'online' and 'disconnected' members of 'struct acc_dev' are placed in separate variables by declaring them each as 'int'. Bug: 173789633 Signed-off-by: Will Deacon <willdeacon@google.com> Change-Id: Ia6031d82a764e83b2cc3502fbe5fb273511da752 Signed-off-by: Giuliano Procida <gprocida@google.com>
-rw-r--r--drivers/usb/gadget/function/f_accessory.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/usb/gadget/function/f_accessory.c b/drivers/usb/gadget/function/f_accessory.c
index 8cafecce5243..a2dc735a9438 100644
--- a/drivers/usb/gadget/function/f_accessory.c
+++ b/drivers/usb/gadget/function/f_accessory.c
@@ -83,13 +83,13 @@ struct acc_dev {
83 /* online indicates state of function_set_alt & function_unbind 83 /* online indicates state of function_set_alt & function_unbind
84 * set to 1 when we connect 84 * set to 1 when we connect
85 */ 85 */
86 int online:1; 86 int online;
87 87
88 /* disconnected indicates state of open & release 88 /* disconnected indicates state of open & release
89 * Set to 1 when we disconnect. 89 * Set to 1 when we disconnect.
90 * Not cleared until our file is closed. 90 * Not cleared until our file is closed.
91 */ 91 */
92 int disconnected:1; 92 int disconnected;
93 93
94 /* strings sent by the host */ 94 /* strings sent by the host */
95 char manufacturer[ACC_STRING_SIZE]; 95 char manufacturer[ACC_STRING_SIZE];