@@ -84,7 +84,7 @@ static void uhid_device_add_worker(struct work_struct *work)
8484 * However, we do have to clear the ->running flag and do a
8585 * wakeup to make sure userspace knows that the device is gone.
8686 */
87- uhid -> running = false;
87+ WRITE_ONCE ( uhid -> running , false) ;
8888 wake_up_interruptible (& uhid -> report_wait );
8989 }
9090}
@@ -194,9 +194,9 @@ static int __uhid_report_queue_and_wait(struct uhid_device *uhid,
194194 spin_unlock_irqrestore (& uhid -> qlock , flags );
195195
196196 ret = wait_event_interruptible_timeout (uhid -> report_wait ,
197- !uhid -> report_running || !uhid -> running ,
197+ !uhid -> report_running || !READ_ONCE ( uhid -> running ) ,
198198 5 * HZ );
199- if (!ret || !uhid -> running || uhid -> report_running )
199+ if (!ret || !READ_ONCE ( uhid -> running ) || uhid -> report_running )
200200 ret = - EIO ;
201201 else if (ret < 0 )
202202 ret = - ERESTARTSYS ;
@@ -237,7 +237,7 @@ static int uhid_hid_get_report(struct hid_device *hid, unsigned char rnum,
237237 struct uhid_event * ev ;
238238 int ret ;
239239
240- if (!uhid -> running )
240+ if (!READ_ONCE ( uhid -> running ) )
241241 return - EIO ;
242242
243243 ev = kzalloc (sizeof (* ev ), GFP_KERNEL );
@@ -279,7 +279,7 @@ static int uhid_hid_set_report(struct hid_device *hid, unsigned char rnum,
279279 struct uhid_event * ev ;
280280 int ret ;
281281
282- if (!uhid -> running || count > UHID_DATA_MAX )
282+ if (!READ_ONCE ( uhid -> running ) || count > UHID_DATA_MAX )
283283 return - EIO ;
284284
285285 ev = kzalloc (sizeof (* ev ), GFP_KERNEL );
@@ -579,7 +579,7 @@ static int uhid_dev_destroy(struct uhid_device *uhid)
579579 if (!uhid -> hid )
580580 return - EINVAL ;
581581
582- uhid -> running = false;
582+ WRITE_ONCE ( uhid -> running , false) ;
583583 wake_up_interruptible (& uhid -> report_wait );
584584
585585 cancel_work_sync (& uhid -> worker );
@@ -593,7 +593,7 @@ static int uhid_dev_destroy(struct uhid_device *uhid)
593593
594594static int uhid_dev_input (struct uhid_device * uhid , struct uhid_event * ev )
595595{
596- if (!uhid -> running )
596+ if (!READ_ONCE ( uhid -> running ) )
597597 return - EINVAL ;
598598
599599 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)
604604
605605static int uhid_dev_input2 (struct uhid_device * uhid , struct uhid_event * ev )
606606{
607- if (!uhid -> running )
607+ if (!READ_ONCE ( uhid -> running ) )
608608 return - EINVAL ;
609609
610610 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)
616616static int uhid_dev_get_report_reply (struct uhid_device * uhid ,
617617 struct uhid_event * ev )
618618{
619- if (!uhid -> running )
619+ if (!READ_ONCE ( uhid -> running ) )
620620 return - EINVAL ;
621621
622622 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,
626626static int uhid_dev_set_report_reply (struct uhid_device * uhid ,
627627 struct uhid_event * ev )
628628{
629- if (!uhid -> running )
629+ if (!READ_ONCE ( uhid -> running ) )
630630 return - EINVAL ;
631631
632632 uhid_report_wake_up (uhid , ev -> u .set_report_reply .id , ev );
0 commit comments