drivers/fsi: Fix SBEFIFO write() race condition
PATCH 1/1 drivers/fsi: Fix SBEFIFO write() race condition
From: "Edward A. James" <[email protected]>
There was a race condition with the XFR_WRITE_DONE flag between write() and the worker thread. Occasionally the worker wrote all the data and checked the flag before write() could set it.
Signed-off-by Edward A. James <[email protected]>
--- drivers/fsi/fsi-sbefifo.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/fsi/fsi-sbefifo.c +6 -1
@@ -688,6 +688,12 @@ static ssize_t sbefifo_write_common(struct sbefifo_client *client, len -= n; ret += n; +/* set flag before starting the worker, as it may run through +* and check the flag before we exit this loop! +*/ +if (!len) +set_bit (SBEFIFO_XFR_WRITE_DONE , &xfr->flags); +/* * Drain the write buffer. */
@@ -696,7 +702,6 @@ static ssize_t sbefifo_write_common(struct sbefifo_client *client,sbefifo_put (sbefifo); } -set_bit (SBEFIFO_XFR_WRITE_DONE , &xfr->flags);sbefifo_put_client (client);return ret;
Signature · 1 line
1.8.3.1
thx Eddie!
Reviewed-by Brad Bishop <[email protected]>
Quoted 40 lines · Eddie James
From: "Edward A. James" <[email protected]>
There was a race condition with the
XFR_WRITE_DONEflag betweenwrite()and the worker thread. Occasionally the worker wrote all the data and checked the flag beforewrite()could set it.Signed-off-by Edward A. James <[email protected]>---
drivers/fsi/fsi-sbefifo.c| 7 ++++++-1 file changed, 6 insertions(+), 1 deletion(-)drivers/fsi/fsi-sbefifo.c +6
-1@@ -688,6 +688,12 @@ static ssize_t sbefifo_write_common(struct sbefifo_client *client, len -= n; ret += n; +/* set flag before starting the worker, as it may run through +* and check the flag before we exit this loop! +*/ +if (!len) +set_bit (SBEFIFO_XFR_WRITE_DONE , &xfr->flags); +/* * Drain the write buffer. */ @@ -696,7 +702,6 @@ static ssize_t sbefifo_write_common(struct sbefifo_client *client,sbefifo_put (sbefifo); } -set_bit (SBEFIFO_XFR_WRITE_DONE , &xfr->flags);sbefifo_put_client (client);return ret;Signature · 1 line
1.8.3.1