aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorCatalin Marinas <catalin.marinas@arm.com>2009-07-08 06:17:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-07-08 12:34:08 -0400
commit0f2f2221b4ad816567394a52643963428fd353cd (patch)
tree9677b25ca9df0bfb59e0bc70e8c19e2b4d3cc0af /drivers
parentd5ce5b40bc66880d1732461d4b47d7fc3331ed30 (diff)
Free struct device in fw_dev_release()
The f_dev in _request_firmware() is allocated via the fw_setup_device() and fw_register_device() calls and its class set to firmware_class (the class release function is fw_dev_release). Commit 6acf70f078ca replaced the kfree(dev) in fw_dev_release() with a put_device() call but my understanding is that the release function is called via put_device -> kobject_put -> kref_put -> koject_release etc. and it should call kfree since it's the last to see this device structure alive. Because of that, the _request_firmware() function on its -ENOENT error path only calls device_unregister(f_dev) which would eventually call fw_dev_release() but there is no kfree (the subsequent put_device call would just make the kref negative). Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> Acked-by: Ming Lei <tom.leiming@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/firmware_class.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index ddeb819c8f87..fc466531260e 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -357,7 +357,7 @@ static void fw_dev_release(struct device *dev)
357 kfree(fw_priv->pages); 357 kfree(fw_priv->pages);
358 kfree(fw_priv->fw_id); 358 kfree(fw_priv->fw_id);
359 kfree(fw_priv); 359 kfree(fw_priv);
360 put_device(dev); 360 kfree(dev);
361 361
362 module_put(THIS_MODULE); 362 module_put(THIS_MODULE);
363} 363}
@@ -408,13 +408,11 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
408 if (retval) { 408 if (retval) {
409 dev_err(device, "%s: device_register failed\n", __func__); 409 dev_err(device, "%s: device_register failed\n", __func__);
410 put_device(f_dev); 410 put_device(f_dev);
411 goto error_kfree_fw_id; 411 return retval;
412 } 412 }
413 *dev_p = f_dev; 413 *dev_p = f_dev;
414 return 0; 414 return 0;
415 415
416error_kfree_fw_id:
417 kfree(fw_priv->fw_id);
418error_kfree: 416error_kfree:
419 kfree(f_dev); 417 kfree(f_dev);
420 kfree(fw_priv); 418 kfree(fw_priv);