diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2009-05-26 18:49:31 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-06-16 00:30:24 -0400 |
commit | 976821d756c53b421d7c58a9ed60125016d330aa (patch) | |
tree | c4da7b73e909439b664cb5e03f602229c6abdc2c /drivers/base | |
parent | 7fcab099795812a8a08eb3b8c8ddb35c3685045f (diff) |
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: Samuel 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: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/firmware_class.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 242770250584..3591ba7ff6f7 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -40,7 +40,7 @@ static int loading_timeout = 60; /* In seconds */ | |||
40 | static DEFINE_MUTEX(fw_lock); | 40 | static DEFINE_MUTEX(fw_lock); |
41 | 41 | ||
42 | struct firmware_priv { | 42 | struct firmware_priv { |
43 | char fw_id[FIRMWARE_NAME_MAX]; | 43 | char *fw_id; |
44 | struct completion completion; | 44 | struct completion completion; |
45 | struct bin_attribute attr_data; | 45 | struct bin_attribute attr_data; |
46 | struct firmware *fw; | 46 | struct firmware *fw; |
@@ -355,6 +355,7 @@ static void fw_dev_release(struct device *dev) | |||
355 | for (i = 0; i < fw_priv->nr_pages; i++) | 355 | for (i = 0; i < fw_priv->nr_pages; i++) |
356 | __free_page(fw_priv->pages[i]); | 356 | __free_page(fw_priv->pages[i]); |
357 | kfree(fw_priv->pages); | 357 | kfree(fw_priv->pages); |
358 | kfree(fw_priv->fw_id); | ||
358 | kfree(fw_priv); | 359 | kfree(fw_priv); |
359 | put_device(dev); | 360 | put_device(dev); |
360 | 361 | ||
@@ -386,7 +387,13 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, | |||
386 | 387 | ||
387 | init_completion(&fw_priv->completion); | 388 | init_completion(&fw_priv->completion); |
388 | fw_priv->attr_data = firmware_attr_data_tmpl; | 389 | fw_priv->attr_data = firmware_attr_data_tmpl; |
389 | strlcpy(fw_priv->fw_id, fw_name, FIRMWARE_NAME_MAX); | 390 | fw_priv->fw_id = kstrdup(fw_name, GFP_KERNEL); |
391 | if (!fw_priv->fw_id) { | ||
392 | dev_err(device, "%s: Firmware name allocation failed\n", | ||
393 | __func__); | ||
394 | retval = -ENOMEM; | ||
395 | goto error_kfree; | ||
396 | } | ||
390 | 397 | ||
391 | fw_priv->timeout.function = firmware_class_timeout; | 398 | fw_priv->timeout.function = firmware_class_timeout; |
392 | fw_priv->timeout.data = (u_long) fw_priv; | 399 | 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 | if (retval) { | 408 | if (retval) { |
402 | dev_err(device, "%s: device_register failed\n", __func__); | 409 | dev_err(device, "%s: device_register failed\n", __func__); |
403 | put_device(f_dev); | 410 | put_device(f_dev); |
404 | goto error_kfree1; | 411 | goto error_kfree_fw_id; |
405 | } | 412 | } |
406 | *dev_p = f_dev; | 413 | *dev_p = f_dev; |
407 | return 0; | 414 | return 0; |
408 | 415 | ||
416 | error_kfree_fw_id: | ||
417 | kfree(fw_priv->fw_id); | ||
409 | error_kfree: | 418 | error_kfree: |
410 | kfree(f_dev); | 419 | kfree(f_dev); |
411 | error_kfree1: | ||
412 | kfree(fw_priv); | 420 | kfree(fw_priv); |
413 | return retval; | 421 | return retval; |
414 | } | 422 | } |