Bug 13670 - Resource leaks in objstrip.c
Summary: Resource leaks in objstrip.c
Status: RESOLVED INVALID
Alias: None
Product: Platform Specific/Hardware
Classification: Unclassified
Component: Alpha (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Richard Henderson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-29 07:56 UTC by Martin Ettl
Modified: 2009-06-29 11:01 UTC (History)
1 user (show)

See Also:
Kernel Version: 2.6.30
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Martin Ettl 2009-06-29 07:56:45 UTC
Hello,

i have checked the source of the linux kernel with a static code analyis tool (cppcheck). It found two resource leaks in file  "linux-2.6.30/arch/alpha/boot/tools/objstrip.c".

cppcheck prints the following output:

[linux-2.6.30/arch/alpha/boot/tools/objstrip.c:134]: (error) Resource leak: fd
[linux-2.6.30/arch/alpha/boot/tools/objstrip.c:134]: (error) Resource leak: ofd


Take a look at file objstrip.c at line 134:


...
	printf("%lu\n", size);
	return 0;
...

Indeed fd and ofd are not closed.
A possible fix might be:
...
	printf("%lu\n", size);
        close(fd);
        close(ofd);
	return 0;
...


Best regards

Ettl Martin
Comment 1 Alan 2009-06-29 11:01:54 UTC
File handles are closed on exit and this is main() returning  - buggy tools methinks

Note You need to log in before you can comment on or make changes to this bug.