Attention is currently required from: Light.
6 comments:
Commit Message:
Memory leaked was caused as data variable wasn't deallocated in some error cases where
the function returned without deallocatiing it.
Please wrap commit message lines at 72 characters, c.f. https://flashrom.org/Development_Guidelines#Commit_message
File pony_spi.c:
Patch Set #1, Line 164: free(data);
We use tabs for indentation, and a tab is 8 characters wide. Please refer to https://flashrom.org/Development_Guidelines#Coding_style
Besides the indentation, this is correct. The shutdown function hasn't been registered (see comment on line 167), so `data` leaks.
Once execution reaches this point, we know that `register_shutdown(pony_spi_shutdown, data)` has been called successfully. This means flashrom will automatically execute the `pony_spi_shutdown()` function before exiting, which in turn calls `free(data)`. So, there's no need to `free(data)` from this point onwards.
Patch Set #1, Line 182: free(data);
This isn't needed because the shutdown function has been registered, which will run `free(data)` already. Adding `free(data)` here would result in a double-free bug.
Patch Set #1, Line 248: free(data);
This isn't needed either, see my comment on line 182.
Patch Set #1, Line 255: free(data);
This won't work. The `register_spi_bitbang_master()` function stores a copy of the `data` pointer and uses it as argument for the `spi_data` parameter of the functions referenced by the `bitbang_spi_master_pony` struct. The memory is released by the `pony_spi_shutdown()` function.
To view, visit change 62724. To unsubscribe, or for help writing mail filters, visit settings.