@@ -84,7 +84,7 @@ static void uhid_device_add_worker(struct work_struct *work)
84
84
* However, we do have to clear the ->running flag and do a
85
85
* wakeup to make sure userspace knows that the device is gone.
86
86
*/
87
- uhid -> running = false;
87
+ WRITE_ONCE ( uhid -> running , false) ;
88
88
wake_up_interruptible (& uhid -> report_wait );
89
89
}
90
90
}
@@ -194,9 +194,9 @@ static int __uhid_report_queue_and_wait(struct uhid_device *uhid,
194
194
spin_unlock_irqrestore (& uhid -> qlock , flags );
195
195
196
196
ret = wait_event_interruptible_timeout (uhid -> report_wait ,
197
- !uhid -> report_running || !uhid -> running ,
197
+ !uhid -> report_running || !READ_ONCE ( uhid -> running ) ,
198
198
5 * HZ );
199
- if (!ret || !uhid -> running || uhid -> report_running )
199
+ if (!ret || !READ_ONCE ( uhid -> running ) || uhid -> report_running )
200
200
ret = - EIO ;
201
201
else if (ret < 0 )
202
202
ret = - ERESTARTSYS ;
@@ -237,7 +237,7 @@ static int uhid_hid_get_report(struct hid_device *hid, unsigned char rnum,
237
237
struct uhid_event * ev ;
238
238
int ret ;
239
239
240
- if (!uhid -> running )
240
+ if (!READ_ONCE ( uhid -> running ) )
241
241
return - EIO ;
242
242
243
243
ev = kzalloc (sizeof (* ev ), GFP_KERNEL );
@@ -279,7 +279,7 @@ static int uhid_hid_set_report(struct hid_device *hid, unsigned char rnum,
279
279
struct uhid_event * ev ;
280
280
int ret ;
281
281
282
- if (!uhid -> running || count > UHID_DATA_MAX )
282
+ if (!READ_ONCE ( uhid -> running ) || count > UHID_DATA_MAX )
283
283
return - EIO ;
284
284
285
285
ev = kzalloc (sizeof (* ev ), GFP_KERNEL );
@@ -579,7 +579,7 @@ static int uhid_dev_destroy(struct uhid_device *uhid)
579
579
if (!uhid -> hid )
580
580
return - EINVAL ;
581
581
582
- uhid -> running = false;
582
+ WRITE_ONCE ( uhid -> running , false) ;
583
583
wake_up_interruptible (& uhid -> report_wait );
584
584
585
585
cancel_work_sync (& uhid -> worker );
@@ -593,7 +593,7 @@ static int uhid_dev_destroy(struct uhid_device *uhid)
593
593
594
594
static int uhid_dev_input (struct uhid_device * uhid , struct uhid_event * ev )
595
595
{
596
- if (!uhid -> running )
596
+ if (!READ_ONCE ( uhid -> running ) )
597
597
return - EINVAL ;
598
598
599
599
hid_input_report (uhid -> hid , HID_INPUT_REPORT , ev -> u .input .data ,
@@ -604,7 +604,7 @@ static int uhid_dev_input(struct uhid_device *uhid, struct uhid_event *ev)
604
604
605
605
static int uhid_dev_input2 (struct uhid_device * uhid , struct uhid_event * ev )
606
606
{
607
- if (!uhid -> running )
607
+ if (!READ_ONCE ( uhid -> running ) )
608
608
return - EINVAL ;
609
609
610
610
hid_input_report (uhid -> hid , HID_INPUT_REPORT , ev -> u .input2 .data ,
@@ -616,7 +616,7 @@ static int uhid_dev_input2(struct uhid_device *uhid, struct uhid_event *ev)
616
616
static int uhid_dev_get_report_reply (struct uhid_device * uhid ,
617
617
struct uhid_event * ev )
618
618
{
619
- if (!uhid -> running )
619
+ if (!READ_ONCE ( uhid -> running ) )
620
620
return - EINVAL ;
621
621
622
622
uhid_report_wake_up (uhid , ev -> u .get_report_reply .id , ev );
@@ -626,7 +626,7 @@ static int uhid_dev_get_report_reply(struct uhid_device *uhid,
626
626
static int uhid_dev_set_report_reply (struct uhid_device * uhid ,
627
627
struct uhid_event * ev )
628
628
{
629
- if (!uhid -> running )
629
+ if (!READ_ONCE ( uhid -> running ) )
630
630
return - EINVAL ;
631
631
632
632
uhid_report_wake_up (uhid , ev -> u .set_report_reply .id , ev );
0 commit comments