firmware loader: fix races during loading firmware
authorMing Lei <ming.lei@canonical.com>
Sat, 4 Aug 2012 04:01:17 +0000 (12:01 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 Aug 2012 20:13:18 +0000 (13:13 -0700)
commit28eefa750b5e16b13bb869c2c4f7d624a43eb48b
tree1bf6575f9884bdb49f9b8340d159b5ced97383e2
parent65710cb6ea315b3ef76a8a3da7be99afcf58d2bb
firmware loader: fix races during loading firmware

This patch fixes two races in loading firmware:

1, FW_STATUS_DONE should be set before waking up the task waitting
on _request_firmware_load, otherwise FW_STATUS_ABORT may be
thought as DONE mistakenly.

2, Inside _request_firmware_load(), there is a small window between
wait_for_completion() and mutex_lock(&fw_lock), and 'echo 1 > loading'
still may happen during the period, so this patch checks FW_STATUS_DONE
to prevent pages' buffer completed from being freed in firmware_loading_store.

Signed-off-by: Ming Lei <ming.lei@canonical.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/firmware_class.c