public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Samuel Ortiz <sameo@linux.intel.com>
To: linux-kernel <linux-kernel@vger.kernel.org>,
	Greg Kroah-Hartmann <greg@kroah.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Marcel Holtmann <holtmann@linux.intel.com>,
	Zhu Yi <yi.zhu@intel.com>, John Linville <linville@tuxdriver.com>
Subject: [PATCH 1/6] firmware: allocate firmware id dynamically
Date: Tue, 26 May 2009 19:40:13 +0200	[thread overview]
Message-ID: <20090526174151.825366168@linux.intel.com> (raw)
In-Reply-To: 20090526174012.423883376@linux.intel.com

[-- Attachment #1: firmware_class.patch --]
[-- Type: text/plain, Size: 2199 bytes --]

From: Samuel Ortiz <sameo@linux.intel.com>

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>

---
 drivers/base/firmware_class.c |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

Index: iwm-2.6/drivers/base/firmware_class.c
===================================================================
--- iwm-2.6.orig/drivers/base/firmware_class.c	2009-05-26 16:30:41.000000000 +0200
+++ iwm-2.6/drivers/base/firmware_class.c	2009-05-26 16:37:20.000000000 +0200
@@ -40,7 +40,7 @@ static int loading_timeout = 60;	/* In s
 static DEFINE_MUTEX(fw_lock);
 
 struct firmware_priv {
-	char fw_id[FIRMWARE_NAME_MAX];
+	char *fw_id;
 	struct completion completion;
 	struct bin_attribute attr_data;
 	struct firmware *fw;
@@ -278,6 +278,7 @@ static void fw_dev_release(struct device
 {
 	struct firmware_priv *fw_priv = dev_get_drvdata(dev);
 
+	kfree(fw_priv->fw_id);
 	kfree(fw_priv);
 	kfree(dev);
 
@@ -309,7 +310,13 @@ static int fw_register_device(struct dev
 
 	init_completion(&fw_priv->completion);
 	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.data = (u_long) fw_priv;
@@ -323,11 +330,14 @@ static int fw_register_device(struct dev
 	retval = device_register(f_dev);
 	if (retval) {
 		dev_err(device, "%s: device_register failed\n", __func__);
-		goto error_kfree;
+		goto error_kfree_fw_id;
 	}
 	*dev_p = f_dev;
 	return 0;
 
+error_kfree_fw_id:
+	kfree(fw_priv->fw_id);
+
 error_kfree:
 	kfree(fw_priv);
 	kfree(f_dev);

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

  reply	other threads:[~2009-05-26 17:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-26 17:40 [PATCH 0/6] firmware: dynamic firmware id allocation Samuel Ortiz
2009-05-26 17:40 ` Samuel Ortiz [this message]
2009-05-26 17:40 ` [PATCH 2/6] atm/ueagle-atm: prepare for FIRMWARE_NAME_MAX removal Samuel Ortiz
2009-05-26 17:40 ` [PATCH 3/6] tuners/xc2028: " Samuel Ortiz
2009-05-26 17:40 ` [PATCH 4/6] dvb/dvb-usb: " Samuel Ortiz
2009-05-26 18:32   ` Michael Krufky
2009-05-26 18:42     ` Samuel Ortiz
2009-05-26 18:44       ` Michael Krufky
2009-05-26 17:40 ` [PATCH 5/6] pcmcia/ds: " Samuel Ortiz
2009-05-26 17:40 ` [PATCH 6/6] firmware: " Samuel Ortiz
2009-05-26 19:04 ` [PATCH 0/6] firmware: dynamic firmware id allocation John W. Linville

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=20090526174151.825366168@linux.intel.com \
    --to=sameo@linux.intel.com \
    --cc=greg@kroah.com \
    --cc=holtmann@linux.intel.com \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=yi.zhu@intel.com \
    /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