2014-04-05 22:37:04

by Christian Engelmayer

[permalink] [raw]
Subject: [PATCH] modpost: Fix ressource leak in read_dump()

Function read_dump() memory maps the input via grab_file(), but fails to call
the corresponding unmap function. Add the missing call to release_file().
Detected by Coverity: CID 1192419

Signed-off-by: Christian Engelmayer <[email protected]>
---
Compile tested - Applies against v3.14 as well as linux-next.
---
scripts/mod/modpost.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 0663556..ea3e2bd 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2113,8 +2113,10 @@ static void read_dump(const char *fname, unsigned int kernel)
s->preloaded = 1;
sym_update_crc(symname, mod, crc, export_no(export));
}
+ release_file(file, size);
return;
fail:
+ release_file(file, size);
fatal("parse error in symbol dump file\n");
}

--
1.8.3.2


Attachments:
signature.asc (836.00 B)

2014-04-06 00:05:44

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH] modpost: Fix ressource leak in read_dump()

On Sun, Apr 06, 2014 at 12:36:49AM +0200, Christian Engelmayer wrote:
> Function read_dump() memory maps the input via grab_file(), but fails to call
> the corresponding unmap function. Add the missing call to release_file().
> Detected by Coverity: CID 1192419

It doesn't matter at all. All memory is freed on exit() in this program.

-Andi

2014-04-08 15:10:05

by Michal Marek

[permalink] [raw]
Subject: Re: [PATCH] modpost: Fix ressource leak in read_dump()

On 2014-04-06 02:05, Andi Kleen wrote:
> On Sun, Apr 06, 2014 at 12:36:49AM +0200, Christian Engelmayer wrote:
>> Function read_dump() memory maps the input via grab_file(), but fails to call
>> the corresponding unmap function. Add the missing call to release_file().
>> Detected by Coverity: CID 1192419
>
> It doesn't matter at all. All memory is freed on exit() in this program.

The leak can disturb in valgrind output.

Michal

2014-04-22 07:39:31

by Rusty Russell

[permalink] [raw]
Subject: Re: [PATCH] modpost: Fix ressource leak in read_dump()

Michal Marek <[email protected]> writes:

> On 2014-04-06 02:05, Andi Kleen wrote:
>> On Sun, Apr 06, 2014 at 12:36:49AM +0200, Christian Engelmayer wrote:
>>> Function read_dump() memory maps the input via grab_file(), but fails to call
>>> the corresponding unmap function. Add the missing call to release_file().
>>> Detected by Coverity: CID 1192419
>>
>> It doesn't matter at all. All memory is freed on exit() in this program.
>
> The leak can disturb in valgrind output.

Yeah. If release_file() didn't exist at all, I'd agree with Andi. As
it is, I've queued the patch (with typo in title fixed).

Thanks!
Rusty.