Skip to content

More fixes for resource leaks and warnings

[email protected] linux-raid 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest19 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/19Grow_Add_device(): dev_open() return a negative fd on errorGrow.c+1 -10 replies
2/19Grow_addbitmap(): don't try to close a file descriptor which failed to openGrow.c+6 -50 replies
3/19Incremental(): Check return value of dev_open() before trying to use itIncremental.c+6 -00 replies
4/19sysfs_unique_holder(): Check read() return value before using as buffer indexsysfs.c+2 -00 replies
5/19remove_devices(): readlink returns -1 on errorManage.c+1 -10 replies
6/19assemble_container_content(): fix memory leakAssemble.c+4 -10 replies
7/19Grow_restart(): free() offsets after useGrow.c+3 -00 replies
8/19Assemble(): don't dup_super() before we need it.Assemble.c+3 -10 replies
9/19Detail(): Remember to free 'avail'Detail.c+2 -10 replies
10/19Grow_reshape(): Fix another 'sra' leakGrow.c+3 -00 replies
11/19enough_fd(): remember to free buffer for avail arrayutil.c+5 -40 replies
12/19Manage_subdevs(): avoid leaking superManage.c+10 -00 replies
13/19IncrementalScan(): Fix memory leakIncremental.c+1 -00 replies
14/19Managa_ro(): free() mdi before exitingManage.c+16 -60 replies
15/19Manage_runstop(): Avoid memory leakManage.c+13 -90 replies
16/19Monitor(): free allocated memory on exitMonitor.c+6 -00 replies
17/19bitmap_fd_read(): fix memory leakbitmap.c+3 -00 replies
18/19validate_geometry_imsm_volume(): Avoid NULL pointer dereferencesuper-intel.c+3 -10 replies
19/19make_parts(): Avoid false positive security warningmdopen.c+7 -71 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/19] More fixes for resource leaks and warnings

From: Jes Sorensen <[email protected]>

Hi,

Another 'small' pile of fixes for various resource leaks, null pointer dereferencing and out of bounds buffer access found by Coverity.

This is the bulk of these for now. Please notice that I haven't touched super-ddf.c at all, and that is probably the single biggest offender. Also note that I haven't addressed a number of warnings in sysfs.c where we know for sure that files aren't bigger than a given size. The tool obviously doesn't know this, so it spews warnings when we strcpy() content we just read. While the code per-ce is probably safe, we may want to switch to strncpy() just to reduce the noise ratio?

Cheers,
Jes

Jes Sorensen (19):
Grow_Add_device(): dev_open() return a negative fd on error Grow_addbitmap(): don't try to close a file descriptor which failed
to open
Incremental(): Check return value of dev_open() before trying to use
it
sysfs_unique_holder(): Check read() return value before using as
buffer index
remove_devices(): readlink returns -1 on error assemble_container_content(): fix memory leak Grow_restart(): free() offsets after use
Assemble(): don't dup_super() before we need it. Detail(): Remember to free 'avail'
Grow_reshape(): Fix another 'sra' leak
enough_fd(): remember to free buffer for avail array Manage_subdevs(): avoid leaking super
IncrementalScan(): Fix memory leak
Managa_ro(): free() mdi before exiting
Manage_runstop(): Avoid memory leak
Monitor(): free allocated memory on exit bitmap_fd_read(): fix memory leak validate_geometry_imsm_volume(): Avoid NULL pointer dereference make_parts(): Avoid false positive security warning

 Assemble.c    |    9 +++++++--
 Detail.c      |    3 ++-
 Grow.c        |   19 +++++++++++++------
 Incremental.c |    7 +++++++
 Manage.c      |   56 ++++++++++++++++++++++++++++++++++++++++----------------
 Monitor.c     |    6 ++++++
 bitmap.c      |    3 +++
 mdopen.c      |   14 +++++++-------
 super-intel.c |    4 +++-
 sysfs.c       |    2 ++
 util.c        |    9 +++++----
 11 files changed, 95 insertions(+), 37 deletions(-)
Signature · 1 line
1.7.6.4