diff options
author | Ming Lei <ming.lei@canonical.com> | 2013-06-06 20:01:48 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-06-06 12:41:57 -0700 |
commit | d6c8aa3906d5d0e4012b9811d6e0928dc7b4cbaf (patch) | |
tree | 3f069378cd5f1b86ebc9c7cb4df0c48842a07c6b /drivers/base/firmware_class.c | |
parent | 93232e46b209821cb66faf40def928e60615f86b (diff) | |
download | talos-obmc-linux-d6c8aa3906d5d0e4012b9811d6e0928dc7b4cbaf.tar.gz talos-obmc-linux-d6c8aa3906d5d0e4012b9811d6e0928dc7b4cbaf.zip |
firmware loader: simplify holding module for request_firmware
module reference doesn't cover direct loading path, so this patch
simply holds the module in the whole life time of request_firmware()
to fix the problem.
Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/firmware_class.c')
-rw-r--r-- | drivers/base/firmware_class.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index caaddefb8d5c..6ede2292f67e 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c @@ -523,8 +523,6 @@ static void fw_dev_release(struct device *dev) struct firmware_priv *fw_priv = to_firmware_priv(dev); kfree(fw_priv); - - module_put(THIS_MODULE); } static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) @@ -852,9 +850,6 @@ static int _request_firmware_load(struct firmware_priv *fw_priv, bool uevent, dev_set_uevent_suppress(f_dev, true); - /* Need to pin this module until class device is destroyed */ - __module_get(THIS_MODULE); - retval = device_add(f_dev); if (retval) { dev_err(f_dev, "%s: device_register failed\n", __func__); @@ -1131,7 +1126,13 @@ int request_firmware(const struct firmware **firmware_p, const char *name, struct device *device) { - return _request_firmware(firmware_p, name, device, true, false); + int ret; + + /* Need to pin this module until return */ + __module_get(THIS_MODULE); + ret = _request_firmware(firmware_p, name, device, true, false); + module_put(THIS_MODULE); + return ret; } EXPORT_SYMBOL(request_firmware); |