diff options
author | Ming Lei <ming.lei@canonical.com> | 2013-06-06 08:01:48 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-06-06 15:41:57 -0400 |
commit | d6c8aa3906d5d0e4012b9811d6e0928dc7b4cbaf (patch) | |
tree | 3f069378cd5f1b86ebc9c7cb4df0c48842a07c6b | |
parent | 93232e46b209821cb66faf40def928e60615f86b (diff) |
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>
-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) | |||
523 | struct firmware_priv *fw_priv = to_firmware_priv(dev); | 523 | struct firmware_priv *fw_priv = to_firmware_priv(dev); |
524 | 524 | ||
525 | kfree(fw_priv); | 525 | kfree(fw_priv); |
526 | |||
527 | module_put(THIS_MODULE); | ||
528 | } | 526 | } |
529 | 527 | ||
530 | static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) | 528 | 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, | |||
852 | 850 | ||
853 | dev_set_uevent_suppress(f_dev, true); | 851 | dev_set_uevent_suppress(f_dev, true); |
854 | 852 | ||
855 | /* Need to pin this module until class device is destroyed */ | ||
856 | __module_get(THIS_MODULE); | ||
857 | |||
858 | retval = device_add(f_dev); | 853 | retval = device_add(f_dev); |
859 | if (retval) { | 854 | if (retval) { |
860 | dev_err(f_dev, "%s: device_register failed\n", __func__); | 855 | dev_err(f_dev, "%s: device_register failed\n", __func__); |
@@ -1131,7 +1126,13 @@ int | |||
1131 | request_firmware(const struct firmware **firmware_p, const char *name, | 1126 | request_firmware(const struct firmware **firmware_p, const char *name, |
1132 | struct device *device) | 1127 | struct device *device) |
1133 | { | 1128 | { |
1134 | return _request_firmware(firmware_p, name, device, true, false); | 1129 | int ret; |
1130 | |||
1131 | /* Need to pin this module until return */ | ||
1132 | __module_get(THIS_MODULE); | ||
1133 | ret = _request_firmware(firmware_p, name, device, true, false); | ||
1134 | module_put(THIS_MODULE); | ||
1135 | return ret; | ||
1135 | } | 1136 | } |
1136 | EXPORT_SYMBOL(request_firmware); | 1137 | EXPORT_SYMBOL(request_firmware); |
1137 | 1138 | ||