@@ -25,11 +25,11 @@ static void hci_cmd_sync_complete(struct hci_dev *hdev, u8 result, u16 opcode,
2525{
2626 bt_dev_dbg (hdev , "result 0x%2.2x" , result );
2727
28- if (hdev -> req_status != HCI_REQ_PEND )
28+ if (READ_ONCE ( hdev -> req_status ) != HCI_REQ_PEND )
2929 return ;
3030
3131 hdev -> req_result = result ;
32- hdev -> req_status = HCI_REQ_DONE ;
32+ WRITE_ONCE ( hdev -> req_status , HCI_REQ_DONE ) ;
3333
3434 /* Free the request command so it is not used as response */
3535 kfree_skb (hdev -> req_skb );
@@ -167,20 +167,20 @@ struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen,
167167
168168 hci_cmd_sync_add (& req , opcode , plen , param , event , sk );
169169
170- hdev -> req_status = HCI_REQ_PEND ;
170+ WRITE_ONCE ( hdev -> req_status , HCI_REQ_PEND ) ;
171171
172172 err = hci_req_sync_run (& req );
173173 if (err < 0 )
174174 return ERR_PTR (err );
175175
176176 err = wait_event_interruptible_timeout (hdev -> req_wait_q ,
177- hdev -> req_status != HCI_REQ_PEND ,
177+ READ_ONCE ( hdev -> req_status ) != HCI_REQ_PEND ,
178178 timeout );
179179
180180 if (err == - ERESTARTSYS )
181181 return ERR_PTR (- EINTR );
182182
183- switch (hdev -> req_status ) {
183+ switch (READ_ONCE ( hdev -> req_status ) ) {
184184 case HCI_REQ_DONE :
185185 err = - bt_to_errno (hdev -> req_result );
186186 break ;
@@ -194,7 +194,7 @@ struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen,
194194 break ;
195195 }
196196
197- hdev -> req_status = 0 ;
197+ WRITE_ONCE ( hdev -> req_status , 0 ) ;
198198 hdev -> req_result = 0 ;
199199 skb = hdev -> req_rsp ;
200200 hdev -> req_rsp = NULL ;
@@ -665,9 +665,9 @@ void hci_cmd_sync_cancel(struct hci_dev *hdev, int err)
665665{
666666 bt_dev_dbg (hdev , "err 0x%2.2x" , err );
667667
668- if (hdev -> req_status == HCI_REQ_PEND ) {
668+ if (READ_ONCE ( hdev -> req_status ) == HCI_REQ_PEND ) {
669669 hdev -> req_result = err ;
670- hdev -> req_status = HCI_REQ_CANCELED ;
670+ WRITE_ONCE ( hdev -> req_status , HCI_REQ_CANCELED ) ;
671671
672672 queue_work (hdev -> workqueue , & hdev -> cmd_sync_cancel_work );
673673 }
@@ -683,12 +683,12 @@ void hci_cmd_sync_cancel_sync(struct hci_dev *hdev, int err)
683683{
684684 bt_dev_dbg (hdev , "err 0x%2.2x" , err );
685685
686- if (hdev -> req_status == HCI_REQ_PEND ) {
686+ if (READ_ONCE ( hdev -> req_status ) == HCI_REQ_PEND ) {
687687 /* req_result is __u32 so error must be positive to be properly
688688 * propagated.
689689 */
690690 hdev -> req_result = err < 0 ? - err : err ;
691- hdev -> req_status = HCI_REQ_CANCELED ;
691+ WRITE_ONCE ( hdev -> req_status , HCI_REQ_CANCELED ) ;
692692
693693 wake_up_interruptible (& hdev -> req_wait_q );
694694 }
0 commit comments