Commit 8813723a authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] firmware loader: pin firmware module

From: Dmitry Torokhov <dtor_core@ameritech.net>

We need to pin the firmware loader module until the last reference to the
firmware class device is dropped and the class device is destroyed.
parent a4f10cfd
...@@ -263,6 +263,8 @@ fw_class_dev_release(struct class_device *class_dev) ...@@ -263,6 +263,8 @@ fw_class_dev_release(struct class_device *class_dev)
kfree(fw_priv); kfree(fw_priv);
kfree(class_dev); kfree(class_dev);
module_put(THIS_MODULE);
} }
static void static void
...@@ -325,6 +327,7 @@ fw_register_class_device(struct class_device **class_dev_p, ...@@ -325,6 +327,7 @@ fw_register_class_device(struct class_device **class_dev_p,
kfree(class_dev); kfree(class_dev);
return retval; return retval;
} }
static int static int
fw_setup_class_device(struct firmware *fw, struct class_device **class_dev_p, fw_setup_class_device(struct firmware *fw, struct class_device **class_dev_p,
const char *fw_name, struct device *device) const char *fw_name, struct device *device)
...@@ -338,6 +341,9 @@ fw_setup_class_device(struct firmware *fw, struct class_device **class_dev_p, ...@@ -338,6 +341,9 @@ fw_setup_class_device(struct firmware *fw, struct class_device **class_dev_p,
if (retval) if (retval)
goto out; goto out;
/* Need to pin this module until class device is destroyed */
__module_get(THIS_MODULE);
fw_priv = class_get_devdata(class_dev); fw_priv = class_get_devdata(class_dev);
fw_priv->fw = fw; fw_priv->fw = fw;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment