lkml.org 
[lkml]   [2005]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] fix leakes in request_firmware_nowait
matthieu castet wrote:
> Hi,
>
>
> request_firmware_nowait wasn't checking return error and forgot to free
> memory in some case.
>
> This patch should fix it.
>
> Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
>
>
And I forgot a case when _request_firmware return an error.

This one should be correct.

Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
Index: linux-2.6.14/drivers/base/firmware_class.c
===================================================================
--- linux-2.6.14.orig/drivers/base/firmware_class.c 2005-10-28 02:02:08.000000000 +0200
+++ linux-2.6.14/drivers/base/firmware_class.c 2005-11-10 22:47:23.000000000 +0100
@@ -511,18 +511,23 @@
{
struct firmware_work *fw_work = arg;
const struct firmware *fw;
+ int ret;
if (!arg) {
WARN_ON(1);
return 0;
}
daemonize("%s/%s", "firmware", fw_work->name);
- _request_firmware(&fw, fw_work->name, fw_work->device,
+ ret = _request_firmware(&fw, fw_work->name, fw_work->device,
fw_work->hotplug);
- fw_work->cont(fw, fw_work->context);
- release_firmware(fw);
+ if (ret < 0)
+ fw_work->cont(NULL, fw_work->context);
+ else {
+ fw_work->cont(fw, fw_work->context);
+ release_firmware(fw);
+ }
module_put(fw_work->module);
kfree(fw_work);
- return 0;
+ return ret;
}

/**
@@ -573,6 +578,8 @@

if (ret < 0) {
fw_work->cont(NULL, fw_work->context);
+ module_put(fw_work->module);
+ kfree(fw_work);
return ret;
}
return 0;
\
 
 \ /
  Last update: 2005-11-10 22:51    [from the cache]
©2003-2011 Jasper Spaans