Commit 976821d7 authored by Samuel Ortiz's avatar Samuel Ortiz Committed by Greg Kroah-Hartman

firmware: allocate firmware id dynamically

The firmware loader has a statically allocated 30 bytes long string for
the firmware id (a.k.a. the firmware file name). There is no reason why
we couldnt allocate it dynamically, and avoid having restrictions on the
firmware names lengths.
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
Cc: Marcel Holtmann <holtmann@linux.intel.com>
Cc: Zhu Yi <yi.zhu@intel.com>,
Cc: John Linville <linville@tuxdriver.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7fcab099
...@@ -40,7 +40,7 @@ static int loading_timeout = 60; /* In seconds */ ...@@ -40,7 +40,7 @@ static int loading_timeout = 60; /* In seconds */
static DEFINE_MUTEX(fw_lock); static DEFINE_MUTEX(fw_lock);
struct firmware_priv { struct firmware_priv {
char fw_id[FIRMWARE_NAME_MAX]; char *fw_id;
struct completion completion; struct completion completion;
struct bin_attribute attr_data; struct bin_attribute attr_data;
struct firmware *fw; struct firmware *fw;
...@@ -355,6 +355,7 @@ static void fw_dev_release(struct device *dev) ...@@ -355,6 +355,7 @@ static void fw_dev_release(struct device *dev)
for (i = 0; i < fw_priv->nr_pages; i++) for (i = 0; i < fw_priv->nr_pages; i++)
__free_page(fw_priv->pages[i]); __free_page(fw_priv->pages[i]);
kfree(fw_priv->pages); kfree(fw_priv->pages);
kfree(fw_priv->fw_id);
kfree(fw_priv); kfree(fw_priv);
put_device(dev); put_device(dev);
...@@ -386,7 +387,13 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, ...@@ -386,7 +387,13 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
init_completion(&fw_priv->completion); init_completion(&fw_priv->completion);
fw_priv->attr_data = firmware_attr_data_tmpl; fw_priv->attr_data = firmware_attr_data_tmpl;
strlcpy(fw_priv->fw_id, fw_name, FIRMWARE_NAME_MAX); fw_priv->fw_id = kstrdup(fw_name, GFP_KERNEL);
if (!fw_priv->fw_id) {
dev_err(device, "%s: Firmware name allocation failed\n",
__func__);
retval = -ENOMEM;
goto error_kfree;
}
fw_priv->timeout.function = firmware_class_timeout; fw_priv->timeout.function = firmware_class_timeout;
fw_priv->timeout.data = (u_long) fw_priv; fw_priv->timeout.data = (u_long) fw_priv;
...@@ -401,14 +408,15 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, ...@@ -401,14 +408,15 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
if (retval) { if (retval) {
dev_err(device, "%s: device_register failed\n", __func__); dev_err(device, "%s: device_register failed\n", __func__);
put_device(f_dev); put_device(f_dev);
goto error_kfree1; goto error_kfree_fw_id;
} }
*dev_p = f_dev; *dev_p = f_dev;
return 0; return 0;
error_kfree_fw_id:
kfree(fw_priv->fw_id);
error_kfree: error_kfree:
kfree(f_dev); kfree(f_dev);
error_kfree1:
kfree(fw_priv); kfree(fw_priv);
return retval; return retval;
} }
......
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