Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936369AbZFPFzV (ORCPT ); Tue, 16 Jun 2009 01:55:21 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751336AbZFPFvH (ORCPT ); Tue, 16 Jun 2009 01:51:07 -0400 Received: from kroah.org ([198.145.64.141]:48337 "EHLO coco.kroah.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759898AbZFPFvD (ORCPT ); Tue, 16 Jun 2009 01:51:03 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Samuel Ortiz , Marcel Holtmann , John Linville , Greg Kroah-Hartman Subject: [PATCH 16/64] firmware: allocate firmware id dynamically Date: Mon, 15 Jun 2009 22:46:05 -0700 Message-Id: <1245131213-24168-16-git-send-email-gregkh@suse.de> X-Mailer: git-send-email 1.6.3.1 In-Reply-To: <20090616051351.GA23627@kroah.com> References: <20090616051351.GA23627@kroah.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2496 Lines: 78 From: Samuel Ortiz 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 Cc: Marcel Holtmann Cc: Zhu Yi , Cc: John Linville Signed-off-by: Greg Kroah-Hartman --- 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 2427702..3591ba7 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; @@ -355,6 +355,7 @@ static void fw_dev_release(struct device *dev) for (i = 0; i < fw_priv->nr_pages; i++) __free_page(fw_priv->pages[i]); kfree(fw_priv->pages); + kfree(fw_priv->fw_id); kfree(fw_priv); put_device(dev); @@ -386,7 +387,13 @@ 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 = 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; @@ -401,14 +408,15 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, if (retval) { dev_err(device, "%s: device_register failed\n", __func__); put_device(f_dev); - goto error_kfree1; + goto error_kfree_fw_id; } *dev_p = f_dev; return 0; +error_kfree_fw_id: + kfree(fw_priv->fw_id); error_kfree: kfree(f_dev); -error_kfree1: kfree(fw_priv); return retval; } -- 1.6.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/