From: Chuansheng Liu <chuansheng.liu@intel.com>
To: ming.lei@canonical.com, gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, chuansheng.liu@intel.com
Subject: [PATCH] firmware loader: Fix the race FW_STATUS_DONE is followed by class_timeout
Date: Thu, 08 Nov 2012 00:45:44 +0800 [thread overview]
Message-ID: <1352306744.15558.1608.camel@cliu38-desktop-build> (raw)
There is a race condition as below when calling request_firmware():
CPU1 CPU2
write 0 > loading
mutex_lock(&fw_lock);
...
set_bit FW_STATUS_DONE class_timeout is coming
set_bit FW_STATUS_ABORT
complete_all &completion
...
mutex_unlock(&fw_lock)
In this time, the bit FW_STATUS_DONE and FW_STATUS_ABORT are set,
and request_firmware() will return failure due to condition in
_request_firmware_load():
if (!buf->size || test_bit(FW_STATUS_ABORT, &buf->status))
retval = -ENOENT;
But from the above scenerio, it should be a succcessful requesting.
So we need judge if the FW_STATUS_DONE is set before calling abort
in timeout function firmware_class_timeout().
Signed-off-by: liu chuansheng <chuansheng.liu@intel.com>
---
drivers/base/firmware_class.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 8945f4e..35fffd8 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -671,6 +671,13 @@ static void firmware_class_timeout(u_long data)
{
struct firmware_priv *fw_priv = (struct firmware_priv *) data;
+ mutex_lock(&fw_lock);
+ if (test_bit(FW_STATUS_DONE, &(fw_priv->buf->status))) {
+ mutex_unlock(&fw_lock);
+ return;
+ }
+ mutex_unlock(&fw_lock);
+
fw_load_abort(fw_priv);
}
--
1.7.0.4
next reply other threads:[~2012-11-07 7:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-07 16:45 Chuansheng Liu [this message]
2012-11-07 10:39 ` Ming Lei
2012-11-08 1:31 ` Liu, Chuansheng
2012-11-08 10:29 ` [PATCH V2] " Chuansheng Liu
2012-11-08 2:01 ` Ming Lei
2012-11-08 2:07 ` Liu, Chuansheng
2012-11-08 11:14 ` [PATCH V3] " Chuansheng Liu
2012-11-08 9:57 ` Ming Lei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1352306744.15558.1608.camel@cliu38-desktop-build \
--to=chuansheng.liu@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@canonical.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®