summaryrefslogtreecommitdiffstats
path: root/tools/perf/scripts/python/check-perf-trace.py
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2013-08-23 14:45:09 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-26 06:41:56 -0700
commita55de0f4931028622e2f6059007454758403f7c0 (patch)
treebe545d20c8e9160a0bde3a969afa36e63b844033 /tools/perf/scripts/python/check-perf-trace.py
parent0f3ce1a600fc1aca996a550f332c9f0c712ea80a (diff)
staging: comedi: comedi_bond: use krealloc() and fix memory leak
`do_dev_config()` is called from the comedi 'attach' handler, `bonding_attach()`. The device private data structure contains a dynamically allocated array of pointers to "bonded" device structures which grows during the `do_dev_config()` call. The length of this array is in `devpriv->ndevs`. It currently uses a local function `realloc()` to allocate a new array, copy the old contents over and free the old array. It should be more efficient to use `krealloc()` as it may be able to use slack space at the end of the previous array and avoid a copy. The old `realloc()` function always freed the old buffer which meant that if it failed to allocate the new buffer it would lose the contents of the old buffer. Unfortunately, that contained pointers to more dynamically allocated memory, leading to a memory leak. If `krealloc()` fails, keep the old buffer and avoid the memory leak. The aforementioned pointers to more dynamically allocated memory will be cleaned up by the 'detach' handler, `bonding_detach()` which will be called by the comedi core as a consequence of `krealloc()` failing in `do_dev_config()`. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/perf/scripts/python/check-perf-trace.py')
0 files changed, 0 insertions, 0 deletions