All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Ortiz <samuel.ortiz@intel.com>
To: Marcel Holtmann <holtmann@linux.intel.com>
Cc: "Zhu, Yi" <yi.zhu@intel.com>,
	"linville@tuxdriver.com" <linville@tuxdriver.com>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	Kay Sievers <kay.sievers@vrfy.org>
Subject: Re: [PATCH 2/3] iwmc3200wifi: shrink calibration lmac name
Date: Tue, 26 May 2009 13:04:11 +0200	[thread overview]
Message-ID: <20090526110403.GA14626@sortiz.org> (raw)
In-Reply-To: <1243327894.30938.9.camel@localhost.localdomain>

Hi Marcel,

On Tue, May 26, 2009 at 01:51:34AM -0700, Marcel Holtmann wrote:
> > > > FIRMWARE_NAME_MAX is defined 30 at this time.
> > > 
> > > I think we need to fix this. Especially since all the other name
> > > length limits in the driver model are gone.
> > 
> > I agree. Should we fix this by simply increasing FIRMWARE_NAME_MAX to
> > some acceptable length (what should it be? btw) or there are other
> > better ideas?
> 
> I think just increasing the length of the static array is bad. Can we
> just not allocated the needed length for the firmware filename?
I think we can, assuming all firmware name strings passed through
request_firmware() are \0 terminated. Based on that assumption, this is what I
propose:

--
 drivers/base/firmware_class.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index d3a59c6..e1e69de 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -40,7 +40,7 @@ static int loading_timeout = 60;	/* In seconds */
 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 *dev)
 {
 	struct firmware_priv *fw_priv = dev_get_drvdata(dev);
 
+	kfree(fw_priv->fw_id);
 	kfree(fw_priv);
 	kfree(dev);
 
@@ -309,7 +310,14 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
 
 	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 = kzalloc(strlen(fw_name) + 1, GFP_KERNEL);
+	if (!fw_priv->fw_id) {
+		dev_err(device, "%s: Firmware name allocation failed\n",
+			__func__);
+		retval = -ENOMEM;
+		goto error_kfree;
+	}
+	strcpy(fw_priv->fw_id, fw_name);
 
 	fw_priv->timeout.function = firmware_class_timeout;
 	fw_priv->timeout.data = (u_long) fw_priv;
@@ -323,11 +331,14 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
 	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/
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


  reply	other threads:[~2009-05-26 11:02 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-26  3:10 [PATCH 1/3] iwmc3200wifi: fix fragmentation threshold setting Zhu Yi
2009-05-26  3:10 ` [PATCH 2/3] iwmc3200wifi: shrink calibration lmac name Zhu Yi
2009-05-26  3:10   ` [PATCH 3/3] iwmc3200wifi: fix link error when CFG80211 is not selected Zhu Yi
2009-05-26  5:42     ` David Miller
2009-05-26  4:43   ` [PATCH 2/3] iwmc3200wifi: shrink calibration lmac name Marcel Holtmann
2009-05-26  6:02     ` Zhu Yi
2009-05-26  6:33       ` Marcel Holtmann
2009-05-26  6:36         ` Christoph Hellwig
2009-05-26  6:36           ` Zhu Yi
2009-05-26  6:41           ` Marcel Holtmann
2009-05-26  6:47         ` Zhu Yi
2009-05-26  8:51           ` Marcel Holtmann
2009-05-26 11:04             ` Samuel Ortiz [this message]
2009-05-26 11:06               ` Kay Sievers
2009-05-26 14:03                 ` Samuel Ortiz
2009-05-26  6:04     ` David Miller
2009-06-01 18:29   ` John W. Linville
2009-06-02  7:52     ` Zhu Yi
2009-06-02  8:09       ` Samuel Ortiz
2009-06-02  7:54     ` Samuel Ortiz
2009-06-02  8:02       ` Marcel Holtmann
2009-06-02  8:24         ` Samuel Ortiz

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=20090526110403.GA14626@sortiz.org \
    --to=samuel.ortiz@intel.com \
    --cc=holtmann@linux.intel.com \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-wireless@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.