aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/firmware_class.c
diff options
context:
space:
mode:
authormatthieu castet <castet.matthieu@free.fr>2005-11-13 19:07:39 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-13 21:14:17 -0500
commit113fab1386f0093602d9f48b424b945cafd3db23 (patch)
tree3d9f0853c2ce8ff846b5156ac91307f4107f3e8d /drivers/base/firmware_class.c
parentff6ed4063da39e6a30ce904005e4ed17385e2739 (diff)
[PATCH] fix leaks in request_firmware_nowait
Wasn't checking return error and forgot to free in some case. Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr> Cc: Greg KH <greg@kroah.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/base/firmware_class.c')
-rw-r--r--drivers/base/firmware_class.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 98f6c02d6790..59dacb6552c0 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -526,18 +526,23 @@ request_firmware_work_func(void *arg)
526{ 526{
527 struct firmware_work *fw_work = arg; 527 struct firmware_work *fw_work = arg;
528 const struct firmware *fw; 528 const struct firmware *fw;
529 int ret;
529 if (!arg) { 530 if (!arg) {
530 WARN_ON(1); 531 WARN_ON(1);
531 return 0; 532 return 0;
532 } 533 }
533 daemonize("%s/%s", "firmware", fw_work->name); 534 daemonize("%s/%s", "firmware", fw_work->name);
534 _request_firmware(&fw, fw_work->name, fw_work->device, 535 ret = _request_firmware(&fw, fw_work->name, fw_work->device,
535 fw_work->hotplug); 536 fw_work->hotplug);
536 fw_work->cont(fw, fw_work->context); 537 if (ret < 0)
537 release_firmware(fw); 538 fw_work->cont(NULL, fw_work->context);
539 else {
540 fw_work->cont(fw, fw_work->context);
541 release_firmware(fw);
542 }
538 module_put(fw_work->module); 543 module_put(fw_work->module);
539 kfree(fw_work); 544 kfree(fw_work);
540 return 0; 545 return ret;
541} 546}
542 547
543/** 548/**
@@ -586,6 +591,8 @@ request_firmware_nowait(
586 591
587 if (ret < 0) { 592 if (ret < 0) {
588 fw_work->cont(NULL, fw_work->context); 593 fw_work->cont(NULL, fw_work->context);
594 module_put(fw_work->module);
595 kfree(fw_work);
589 return ret; 596 return ret;
590 } 597 }
591 return 0; 598 return 0;