From: Ming Lei <ming.lei@canonical.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, Ming Lei <ming.lei@canonical.com>
Subject: [PATCH 2/3] firmware loader: simplify holding module for request_firmware
Date: Wed, 5 Jun 2013 13:42:48 +0800 [thread overview]
Message-ID: <1370410969-15328-3-git-send-email-ming.lei@canonical.com> (raw)
In-Reply-To: <1370410969-15328-1-git-send-email-ming.lei@canonical.com>
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>
---
drivers/base/firmware_class.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 34d47e3..c743409 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__);
@@ -1127,7 +1122,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);
--
1.7.9.5
next prev parent reply other threads:[~2013-06-05 5:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-05 5:42 [PATCH 0/3] firmware loader: cleanup and introduce search paths option Ming Lei
2013-06-05 5:42 ` [PATCH 1/3] firmware loader: don't export cache_firmware and uncache_firmware Ming Lei
2013-06-05 5:42 ` Ming Lei [this message]
2013-06-05 5:42 ` [PATCH 3/3] firmware loader: allow distribution to choose default search paths Ming Lei
2013-06-05 7:10 ` Takashi Iwai
2013-06-05 9:35 ` Ming Lei
2013-06-05 9:50 ` Takashi Iwai
2013-06-05 9:59 ` Ming Lei
2013-06-05 10:28 ` Ming Lei
2013-06-05 11:57 ` Takashi Iwai
2013-06-05 12:36 ` Ming Lei
2013-06-05 12:45 ` Takashi Iwai
2013-06-05 12:54 ` 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=1370410969-15328-3-git-send-email-ming.lei@canonical.com \
--to=ming.lei@canonical.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/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®