forked from luck/tmp_suning_uos_patched
fault_inject: Don't rely on "return value" from WRITE_ONCE()
It's a bit weird that WRITE_ONCE() evaluates to the value it stores and it's different to smp_store_release(), which can't be used this way. In preparation for preventing this in WRITE_ONCE(), change the fault injection code to use a local variable instead. Cc: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Will Deacon <will@kernel.org>
This commit is contained in:
parent
9a8939490d
commit
9b4fb5cec0
|
@ -106,7 +106,9 @@ bool should_fail(struct fault_attr *attr, ssize_t size)
|
|||
unsigned int fail_nth = READ_ONCE(current->fail_nth);
|
||||
|
||||
if (fail_nth) {
|
||||
if (!WRITE_ONCE(current->fail_nth, fail_nth - 1))
|
||||
fail_nth--;
|
||||
WRITE_ONCE(current->fail_nth, fail_nth);
|
||||
if (!fail_nth)
|
||||
goto fail;
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue
Block a user